admin管理员组文章数量:1389783
On this online platform project i have requested all users to add in their school title.
In the user dashboard there is a posts section which currently shows all posts. I want to only show posts that belong to users from the same school or institute.
I am working in the child theme and have possibly found out i would need:
add_filter( 'hook_into_theme', 'my_posts_filter');
I also understand, may be wrong, that i would need an array possibly. So the key is institute : value (whatever the users put it as)
$args = array(
'meta_query' => array(
array(
'key' => 'school',
'value' => $??? what do i put here $current_user->ID,
'compare' => '='
)
)
);
How would i combine the function and the array to work to filter posts to only show those from the same school??
Here is my try:
add_filter( 'theme_customisation_hook', 'my_posts_filter');
function my_posts_filter ($args) {
$args = array(
'meta_query' => array(
array(
'key' => 'school',
'value' => $current_user->ID,
'compare' => '='
)
)
);
}
Does this make any sense?
本文标签: wp queryHow to filterrestrict and return posts based on custom user meta information
版权声明:本文标题:wp query - How to filter, restrict and return posts based on custom user meta information 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744589371a2614392.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论