我使用的代码调用了上传到帖子中的所有附件。我添加了图库自定义帖子类型,但没有显示任何内容。
但这在我的“漂亮的小骗子”帖子类型上有所体现。我做错了什么。
<?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>\';
}
}
?>