我想使用帖子ID检索帖子。 但我发现它根据自定义帖子类型而不是帖子ID检索帖子。这是我的代码。请给我一些建议。
$args = array(
'post_type' => 'landingpage',
'post_id' => '4110',
'post_status' => 'publish',
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'page_link',
'value' => 'http://5.heypayless/Landing%20Pages/dedicated-web-programmers/',
'compare' => '='
)
)
);
$obituary_query = new WP_Query($args);
while ($obituary_query->have_posts()) : $obituary_query->the_post();
$test= get_field('price/hr_for_test_services');
$junior=get_field('price/hr_for_junior');
$senior=get_field('price/hr_for_senior');
$lead=get_field('price/hr_for_lead_designer');
$features=get_field('features_for_test_services');
$features2=get_field('features_for_junior');
$features3=get_field('features_for_senior');
$features4=get_field('features_for_lead_designer');
endwhile;
echo $post->ID;
wp_reset_postdata();
?>
答案 0 :(得分:0)
$args = array( 'p' => 42, // id of a page, post, or custom type 'post_type' => 'any');
$my_posts = new WP_Query($args);
答案 1 :(得分:0)
WP_Query没有post_id
参数。您需要使用page_id
代替。类型为int
而不是string
:
...
'page_id' => 4110,
...