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>';


1 Answer 1

if ( 'pretty-little-liars' == get_post_type() || 'gallery' == get_post_type() ) {
    // ...

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.