w__query,post_id不起作用

时间:2015-03-27 12:53:09

标签: wordpress wp-query

我想使用帖子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();

    ?>

2 个答案:

答案 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,

...