Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

   <?php

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
add comment

1 Answer

up vote 1 down vote accepted
<?php
if ( 'pretty-little-liars' == get_post_type() || 'gallery' == get_post_type() ) {
    // ...
}
?>
share|improve this answer
add comment

Your Answer

 
discard

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.