admin管理员组

文章数量:1287569

I have a custom post type "issues".

I am using Advanced Custom Fields to add a relational field called "articles_from_this_issue" where the admin can select multiple articles.

I have an author template where I display all of the authors posts (articles).

I need to query the "issues" custom post type and check to see if each article is one of the selected "articles_from_this_issue"

here is what I have tried so far but nothing seems to work.

$issues_args = array(
    'post_type' => 'issues', 
    'meta_query' => array(
        'relation' => 'OR',
        array(
            'key' => 'articles_from_this_issue',
            'value' => serialize( intval(get_the_ID()) ),
            'compare' => 'LIKE'
        ),
    ));

$the_issues_query = new WP_Query( $issues_args ); 

I have also tried this:

$issues_args = array(
'post_type' => 'issues', 
'meta_query' => array(
    array(
        'key' => 'articles_from_this_issue',
        'compare' => 'LIKE',
        'value' => get_the_ID(),
    ),
));

Here is what the database shows in the "wp_postmeta" table:

meta_id: 27533
post_id: 733
meta_key: articles_from_this_issue
meta_value: a:2:{i:0;s:4:"3187";i:1;s:4:"3230";}

Any and all help is much appreciated!

本文标签: phpQuery custom post type that has a serialized relational advanced custom field value