0
我有自定义帖子类型umowy
哪一个与用户有关系。关系是由编辑用户通过acf添加的。我想要的是?我想列在仪表板自定义帖子类型umowy
所有与用户登录有关系的帖子。我有这样的代码。它的显示帖子仅供用户登录哪一个是作者。有人有想法吗?WordPress的过滤仪表板自定义帖子由用户与关系
add_action('pre_get_posts', 'filter_posts_list');
function filter_posts_list($query)
{
//$pagenow holds the name of the current page being viewed
global $pagenow, $typenow;
//$current_user uses the get_currentuserinfo() method to get the currently logged in user's data
global $current_user;
get_currentuserinfo();
//Shouldn't happen for the admin, but for any role with the edit_posts capability and only on the posts list page, that is edit.php
if(!current_user_can('administrator') && current_user_can('edit_posts') && ('edit.php' == $pagenow) && $typenow == 'umowy')
{
//global $query's set() method for setting the author as the current user's id
$query->set('author', $current_user->ID);
}
}