按parent_id检索自定义帖子类型不起作用(Wordpress)

时间:2019-03-07 19:41:02

标签: php wordpress custom-post-type

我想检索某个parent_id的所有交易(自定义帖子类型) 这是查询:

$loop = new WP_Query(['post_type' => 'deals', 'post_parent' => $post->ID, 'posts_per_page' => -1]

并将发布定义为全局$ post;但是,如果我在某个帖子页面上,它将向我显示所有交易,但是我只想查看具有parent_id = $ post-> ID的交易。交易(帖子类型)的创建如下:

$data = [
        'post_parent'       => $postParent, // This one is hardcoded 749, the custom post ID of the one i choose.
        'post_type'         => 'deals',
        'post_title'        => $dealData['dealName'],
        'post_name'         => $dealData['dealName'],
        'post_status'       => 'publish',
        'comment_status'    => 'closed',
        'post_category'     => $dealData['country_category_id'],
    ];

我做错什么了吗?

0 个答案:

没有答案