我试图使帖子的自定义metabox陷入循环,但无法正常工作。我需要在args中通过meta_query进行调用吗?或者我可以直接进入循环?我在wordpress开发人员网站上查看但无法正常工作。
<?php
global $post;
$args = array(
'posts_per_page' => 5,
'offset' => 0,
'cat' => '',
'category_name' => 'new-posts',
'orderby' => 'date',
'order' => 'DESC',
'include' => '',
'exclude' => '',
'meta_key' => 'rd_custom_title',
'meta_value' => '',
'post_type' => 'post',
'post_mime_type' => '',
'post_parent' => '',
'author' => '',
'author_name' => '',
'post_status' => 'publish',
'suppress_filters' => true,
'fields' => '',
'meta_query' => array(
array(
'key' => '_thumbnail_id',
'compare' => 'EXISTS'
),
)
);
$myposts = get_posts( $args );
foreach ( $myposts as $post ) : setup_postdata( $post ); ?>
<li>
<?php the_post_thumbnail(); ?>
<?php get_post_meta($post_id, 'rd_custom_title', true); ?>
<?php get_post_meta($post->ID, 'rd_custom_title', true); ?>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
</li>
<?php endforeach;
wp_reset_postdata();?>