Я пытался зациклить пользовательский метабокс постов, но не работал. Мне нужно вызвать meta_query в args? или я могу попасть прямо в петлю? Я проверяю сайт разработчика 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();?>