Forums

How to show parent-gallery on image.php (6 posts)

  1. stereopoly
    Member
    Posted 7 months ago #

    hey! just one little question: how can i show the original gallery of one post on the image.php?

  2. mfields
    Member
    Posted 7 months ago #

    How does 2 lines of code sound?

    $gallery_shortcode = '[gallery id="' . intval( $post->post_parent ); . '"]';
    print apply_filters( 'the_content', $gallery_shortcode );
  3. stereopoly
    Member
    Posted 7 months ago #

    sounds nice. but i'm not good in php. how do i put it into my image.php? still missin some <?php-stuff, right?

  4. mfields
    Member
    Posted 7 months ago #

    yep...

    <?php
    $gallery_shortcode = '[gallery id="' . intval( $post->post_parent ); . '"]';
    print apply_filters( 'the_content', $gallery_shortcode );
    ?>
  5. stereopoly
    Member
    Posted 7 months ago #

    does not work :(

  6. mfields
    Member
    Posted 7 months ago #

    Sorry, there was a typo in the code I posted above. Try this:

    <?php
    $gallery_shortcode = '[gallery id="' . intval( $post->post_parent ) . '"]';
    print apply_filters( 'the_content', $gallery_shortcode );
    ?>

Reply

You must log in to post.

About this Topic