• Hi Guys,

    I want to display the wordpress built in gallery shortcode outside of the_content(); loop.

    I have added the following to my themes functions.php file

    add_filter('the_content', 'strip_shortcodes');

    I have then added the following into my themes template file.

    <?php echo do_shortcode('[gallery]'); ?>

    The problem I am having is that for example I create the gallery inside the editor which looks like the following.

    [gallery columns="1" ids="225,117,100" orderby="rand"]

    The gallery is going to change on a post by post basis, so how do I add the code for WordPress to fill these id’s, cols and orderby inside the do_shortcode template tag????

    Because this is a single.php template which I am using it needs to dynamically generate the id’s for that post into the shortcode.

    I am hoping somebody could help me with this. The code works if I directly input the full shortcode into the template. But obviously I want to have it generate it dynamically depending on the gallery setup.

    Hopefully somebody can solve this for me or suggest a way to do it. I have the content text in a left hand column and the gallery in a separate column in a different position on the page.

    Help would be great appreciated.

    Cheers Dan

  • The topic ‘Displaying WordPress Gallery Shortcode outside of the_content’ is closed to new replies.