• Resolved tlkativ

    (@tlkativ)


    I also posted this in the Simple Hooks forum as I am not quite sure which plug-in is causing the problem.

    I am trying to display a shortcode for the List Related Attachments plug-in in the post-meta area using Genesis Simple Hooks but whenever I check both “Execute Shortcodes on this hook?” and “Execute PHP on this hook?” the shortcode disappears. The shortcode works without the PHP but then the attachment doesn’t display on the category archive. Am I not allowed to use this shortcode in a template?

    Here is my code:
    \\
    <?php if (is_archive(‘rides’)) { ?>
    [list-related-attach]
    <?php } ?>
    \\

    https://www.ads-software.com/extend/plugins/list-related-attachments-widget/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Baden

    (@baden03)

    in php, you will want to use do_shortcode

    Thread Starter tlkativ

    (@tlkativ)

    Baden, thanks for the suggestion. I also tried that but the shortcode doesn’t work with just the “Execute PHP on the hook?” checked. Nothing shows up. Am I missing something in my code?

    <?php if (is_archive(‘rides’)) {
    echo do_shortcode(‘[list-related-attach]’);
    } ?>

    Plugin Author Baden

    (@baden03)

    Tlkativ,

    You might want to brush up on your is_archive function:

    is_archive() does not accept any parameters. If you want to check if this is the archive of a custom post type, use is_post_type_archive( $post_type )

    So… what is ‘rides’ exactly? Is it a post type? A page slug?

    Step 1: get this to work:

    if (is_archive()) {
         echo 'Hey Dude';
    }

    Step 2. Once the above works, then just echo the do_shortcode as you posted above:

    if (is_archive()) {
         echo do_shortcode('[list-related-attach]');
    }

    Hope this helps get you squared away.

    Thread Starter tlkativ

    (@tlkativ)

    Baden,

    Thanks again. The ‘Hey Dude’ showed up perfectly (as expected), but as soon as I swapped in the shortcode, the code disappeared. ‘Rides’ is a custom post type but I am trying to get the attachments to show on a category archive page as you guessed. The post_type_archive call gave me the same results.

    It seems like the Simple Hooks doesn’t recognize both php and shortcodes in the same field area. Is there something I can add to my functions.php file to help this along?

    Plugin Author Baden

    (@baden03)

    Sounds like an issue with Simple Hooks not dealing with do_shortcode. OK, then try this:

    <?php
    if (is_archive()) {
    ?>
         [list-related-attach]
    <?php
    }
    ?>

    Thread Starter tlkativ

    (@tlkativ)

    Baden,

    That code above was what I started with and it didn’t work. However, after exploring the issue a little more, I noticed that the shortcode was working on certain archive pages and not on others. So, if I find out why that is I will post an update here. Thanks for your help.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘[Plugin: List Related Attachments] Shortcode not working in archive view’ is closed to new replies.