0

I'm trying to include a gallery in my custom post type. The image gallery works in the editor, but when I view the post I get this.

[gallery link="file" ids="590,589,588,587,586,585,578,580,581,582,583,584"]

My content looks like this:

<?php if ( have_posts() ) : while ( have_posts() ) : the_post();

    $content = get_the_content();
    /** ... **/
?>
    <p><?php echo $content ; ?></p>

enter image description here

3
  • Does your template use the_content() to output post content?
    – Milo
    Feb 2, 2016 at 17:37
  • Does your theme have any filters on the_content? Have you tried disabling all plugins and switching to the default theme to narrow down your issue?
    – Howdy_McGee
    Feb 2, 2016 at 18:00
  • @Howdy_McGee thanks for the reply, managed to figure it out with Milo's help.
    – Peekay
    Feb 2, 2016 at 18:03

1 Answer 1

4

Remove:

$content = get_the_content();

and replace:

<p><?php echo $content; ?></p>

with:

<?php the_content(); ?>

See this note on the Codex page for get_the_content():

An important difference from the_content() is that get_the_content() does not pass the content through the 'the_content' filters. This means that get_the_content() will not auto-embed videos or expand shortcodes, among other things.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.