[Resolved] Further to GP Hooks

Home Forums Support [Resolved] Further to GP Hooks

Home Forums Support Further to GP Hooks

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #247486
    Lyle

    Hi Tom,

    Thought that I would ask here if that’s OK.

    Further to this post from the GP Addon forum:

    https://generatepress.com/forums/topic/hook-question/

    You posted this as a PHP solution for an array of pages to exclude:

    <?php if ( ! is_page( array( 'my-excluded-page-slug', 'another-page', 'one-more' ) ) ) : ?>
        <?php echo do_shortcode( '[your-shortcode]' ); ?>
    <?php endif; ?>

    This works great with the GP Hooks πŸ™‚ However, how would one adjust this code to also exclude a post category named Blog? I tried a few things, even from Stack Overflow, but all I got were errors on those post pages πŸ™

    Any assistance will be greatly appreciated and I promise to get some GP and GP Premium tutorials up ASAP πŸ™‚

    Cheers!
    Lyle

    #247676
    Tom
    Lead Developer
    Lead Developer

    Conditionals can get pretty complex when you start having multiple parameters.

    You could try this:

    <?php if ( ( ! is_page( array( 'my-excluded-page-slug', 'another-page', 'one-more' ) ) ) || ! is_category( 'blog' ) ) : ?>
        <?php echo do_shortcode( '[your-shortcode]' ); ?>
    <?php endif; ?>
    #247823
    Lyle

    Hmm, once I updated with that code (using my values for pages and the blog category (as that is what it is named), the shortcode now displays everywhere πŸ™‚

    I may just end up doing this scenario manually πŸ™‚

    Basically, what I am trying to achieve is have a notice (created with Elementor and using the AnyWhere ELementor plugin shortcode to display it) displayed on all of the SV tutorial pages only and nowhere else. That is why I was thinking, OK, use the !page and list all the main menu items and then the !category so as not to appear on the posts in that category.

    I could manually add that shortcode to each of those tutorial pages, but the hook method would make it “auto-magic” for all new tutorial pages … just me being lazy πŸ™‚

    #247840
    Jamal

    Hi Lyle

    Maybe its easier to target a specific category/ page than excluding everything else except that category/page?

    You could put all the tutorials in a tutorial category and target that tutorial page/ and category?

    #247847
    Lyle

    Hi Jamal,

    Yes, that would probably work better but unfortunately all the tutorials are pages, not posts.

    #247855
    Jamal

    Looking at your site i see /tutorials/tutorial-name, are you using Tom’s wpsp plugin? maybe its possible to target wpsp_id?

    Sorry if that doesnt help either.

    #247856
    Lyle

    Only using WPSP for the Tutorials page, the individual tutorial pages are just pages.

    But it’s a moot point now … for the time being anyway … as I have just finished manually adding the shortcode to each of the required pages πŸ™‚

    I’ll maybe revisit this later, but for now, I’ll mark it Resolved.

    #247876
    Tom
    Lead Developer
    Lead Developer

    If you need more help with that conditional in the future just let me know πŸ™‚

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.