admin管理员组文章数量:1336110
In our intranet we have 120 locations => 120 groups => 120 Categories and 120 authors. in the home page we want to display a carousel, where we will show post's titles (with link) according to the group For example, the group1 will see a carousel with articles from category1, group2 will see a carousel with articles from category2 .... Of course, authors will continue to feed their categories, how will stored in the carousel by date
Any idea about who can I do that ? Thank you
In our intranet we have 120 locations => 120 groups => 120 Categories and 120 authors. in the home page we want to display a carousel, where we will show post's titles (with link) according to the group For example, the group1 will see a carousel with articles from category1, group2 will see a carousel with articles from category2 .... Of course, authors will continue to feed their categories, how will stored in the carousel by date
Any idea about who can I do that ? Thank you
Share Improve this question asked May 19, 2020 at 14:33 WebilixWebilix 1 2- Welcome to WPSE. What kind of content locations and groups are? Are they custom post types, custom taxonomies? Is group a custom user role? Authors are presumably users with Author role, right? – Antti Koskinen Commented May 19, 2020 at 19:18
- Thank you for your response/questions - We want to create a Category per city (eg: News NY, News Miami, ...), we have an author per city, for users they are dispatched on roles (NY_users, Miami_users,...) but all of them are subscribers - please tell me if you need more details – Webilix Commented May 19, 2020 at 20:36
1 Answer
Reset to default 0One option could be to have some kind of lookup table, either hard coded or as a settings page, where you map role (user group) to category (city). Then use the current user object to get city based role and use it as a key to get a category ID from the lookup table, which you use in your post query.
Pseudo-code example,
// Current user data
$current_user = wp_get_current_user();
// Get city role
$city_based_role = some_function_to_get_city_role_from_roles($current_user->roles);
// Get category id
$city_category = some_function_to_get_category_id_from_role_to_category_lookup_table($city_based_role);
// Query posts for category
$args = array(
// some args
'cat' => $city_category,
);
$query = new WP_Query($args);
本文标签: categoriesDisplay the articles of a category by role
版权声明:本文标题:categories - Display the articles of a category by role 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742403529a2468357.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论