• I currently have a number of posts using featured images (full sized on the post page, thumbnail size on the category page) and I would like to add a a gallery to a few of the posts.

    In order to lay out the post the way I would like, I need the gallery grouped with the featured image, the easiest way to do this would be to the gallery to the actual PHP page inside the same <div> as the featured image code. Is there any way to do this? Or am I forced to use the gallery shortcode.

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    You are not forced to do anything! 🙂

    You could directly call the gallery’s shortcode handler and echo out the return. Or make a copy of the handler, edit it any way you want, then call/echo that instead. Or use another gallery plugin altogether.

    I’m not quite sure what you are really asking. I think you want the gallery shortcode output to occur with some template output instead of within post content. Perhaps the easiest way to do so is:
    echo do_shortcode('[gallery]');
    This must be within “The Loop”. Outside the loop, call gallery_shortcode() (the shortcode handler) and pass the desired post ID as the “id” argument.

    By doing this you lose the ability to edit the gallery through the usual media library interface. As a workaround, temporarily add “[gallery]” to post content, edit the gallery as needed, then remove “[gallery]“.

Viewing 1 replies (of 1 total)

The topic ‘WordPress Gallery inside the PHP template’ is closed to new replies.