我什么都试过了。我使用简单的字段,没有问题,在单一的帖子页面像single.php的值,但似乎没有在循环中工作。我需要获得字段值与slug $valutazione0在循环中的每个帖子。下面是我尝试过的代码。当然,我已经仔细查看了支持网站http://simple-fields.com/documentation/api/getting-values/simple_fields_values/
$postID = $post->ID;
$valutazione = simple_fields_values("valutazione0"[,$postID]);
或
$postID = $post->ID;
$valutazione = simple_fields_values($postID, "valutazione0");
或
$postID = $post->ID;
$valutazione = simple_fields_value($postID, "valutazione0");
或
$valutazione = simple_fields_values("$valutazione0"[,the_ID()]);
或
$valutazione = simple_fields_values("$valutazione0"[,<?php the_ID(); ?>]);
或
$valutazione = simple_fields_values("$valutazione0");
或
$valutazione0 = simple_fields_get_post_value(get_the_id(), array(3, 1), true);
最后一个是我一直在单个帖子页面中使用的,在那里它工作没有问题。请帮忙,提前谢谢,Matt
我总是这样做:
$args = array(
'post_type' => 'post' //post type by default
);
$my_query = new WP_Query( $args );
if( $my_query->have_posts() ) {
while( $my_query->have_posts() ) {
$my_query->the_post();
$identificador = $my_query->post->ID;
$nombre = $my_query->post->post_title;
} // end while
} // end if
wp_reset_postdata();
希望对你有所帮助