WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The code i use calls for all attachments that are uploaded to be in the post. I added the Gallery custom post type but nothing shows.

It shows on my "pretty-little-liars" post type though. What am I doing wrong.


if ( 'pretty-little-liars','gallery' == get_post_type() ) { //condition to show     gallery on post type - gallery

if ( $attachments = get_children( array(
    'post_type' => 'attachment',
    'post_mime_type'=>'image',   //return all image attachment only
    'numberposts' => -1,   //get all the attachments
    'post_parent' => $post->ID

foreach ($attachments as $attachment) {
    // you can customize the oputput
    echo '<li><p class="alignleft">';
    echo ''.wp_get_attachment_link( $attachment->ID,'full' , false, false );
    echo '</p>';
    echo ''.$attachment->post_excerpt.'<br><br>';
    echo '<p class="alignright"><h5>'.$attachment->post_title. '</h5>';
    echo ''.$attachment->post_content.'';
    echo '</p></li>';

share|improve this question
up vote 1 down vote accepted
if ( 'pretty-little-liars' == get_post_type() || 'gallery' == get_post_type() ) {
    // ...
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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