我创建了一个自定义字段,并将“按角色筛选”选择为“订阅者”,并将自定义字段分配给帖子类型。现在,当我添加一个新帖子并分配订阅者时(即:创建一个测试帖子并将订阅者分配到“1级”),在我再次单击更新后,我将订阅者“1级”更改为“2级”,之后,当我以1级登录查看页面时,会查看特定帖子。只有当我编辑帖子并再次更改订阅者时,才会发生这种情况。
$args_events = array(
\'post_type\' => \'parents_login\',
\'post_status\' => \'publish\',
\'paged\' => $page_num,
\'posts_per_page\' => CUSTOM_ROWS_PER_PAGE,
\'cat\' => get_cat_id( single_cat_title("",false) ),
\'meta_query\' => array(
\'relation\' => \'OR\',
array(
\'key\' => \'select_grade\',
\'value\' => $current_user->ID,
\'compare\' => \'LIKE\',
),
),
);
SO网友:Sindhu
$args_events = array(
\'post_type\' => \'parents_login\',
\'post_status\' => \'publish\',
\'posts_per_page\' => CUSTOM_ROWS_PER_PAGE,
\'cat\' => get_cat_id( single_cat_title("",false) ),
\'meta_query\' => array(
array(
\'key\' => \'select_grade\',
\'value\' => serialize( strval( $current_user->ID ) ),
\'compare\' => \'LIKE\'
),
),
);
用这个我得到了结果。谢谢