[Resolved] Adding Conditional code in Hooks

Home Forums Support [Resolved] Adding Conditional code in Hooks

Home Forums Support Adding Conditional code in Hooks

  • This topic has 23 replies, 3 voices, and was last updated 2 years ago by Tom.
Viewing 9 posts - 16 through 24 (of 24 total)
  • Author
    Posts
  • #1270461
    GeneratePressUser

    Hello,

    Yes, is it possible for you to email me, I will share with u account details so that u get better idea of it and will share there screenshot for the same things to better understand, I canโ€™t share here in public.

    #1270465
    David
    Staff
    Customer Support

    You can send information and URLs via the Account Issue form here:

    https://generatepress.com/contact/

    #1270871
    GeneratePressUser

    Hello David,

    Done, all things sent via that form ๐Ÿ™‚

    #1271273
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    It’s pretty difficult to debug something like this without digging deep into the code of the shortcodes, which isn’t really something we can do.

    We can help debug though. For example, is it any two shortcodes, or only a specific pair of shortcodes?

    You could try doing something like this:

    <?php 
    if ( is_single( 'post-id' ) ) {
        echo do_shortcode( '[Custom shortcode 1]' );
        echo do_shortcode( '[Custom shortcode 2]' );
    }
    ?>

    Then un-check the “Execute Shortcodes” option.

    #1271384
    GeneratePressUser

    Hello Tom,

    Yes, I can understand, even I don’t want to dig deep into debugging code of shortcodes nor I want you guys to do that.

    I will test the code which you gave and let you know how it goes.

    #1271386
    GeneratePressUser

    Hello Tom,

    Brilliant! That solved it lol.

    Any idea what could have caused that?

    Btw in same format:

    <?php
    if ( is_single( ‘post-id’ ) ) {
    echo do_shortcode( ‘[Custom shortcode 1]’ );
    echo do_shortcode( ‘[Custom shortcode 2]’ );
    }
    ?>

    Can you pls give me code to write custom html code in it? like right now it’s echo do_shortcode so what to write to execute something other than shortcode?

    #1272453
    Tom
    Lead Developer
    Lead Developer

    When you execute shortcodes in the hook, it wraps the entire content in a do_shortcode() function. Perhaps it didn’t like executing multiple shortcodes at once.

    You can add HTML like this:

    <?php
    if ( is_single( 'post-id' ) ) {
        echo '<div class="first-shortcode">';
            echo do_shortcode( '[Custom shortcode 1]' );
        echo '</div>';
    
        echo '<div class="second-shortcode">';
            echo do_shortcode( '[Custom shortcode 2]' );
        echo '</div>';
    }
    ?>
    #1272511
    GeneratePressUser

    Got it, thanks a lot ๐Ÿ™‚

    #1272855
    Tom
    Lead Developer
    Lead Developer
Viewing 9 posts - 16 through 24 (of 24 total)
  • You must be logged in to reply to this topic.