最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

functions - Exclude admins from query get posts

programmeradmin1浏览0评论

We are using this code to see if the user has posted, however we wish to exclude admins. Currently if the role is admin, the function returns a post count.

<?php
$args = array(
    'post_type' => 'post',
    'post_status' => 'publish',
    'author' => get_the_author_meta('ID'),
    'fields' => 'ids',
);
$wp_posts = get_posts($args);
if(count($wp_posts)) : ?>

I tried 'role' => 'contributor' in the $args but the admin is still being included.

发布评论

评论列表(0)

  1. 暂无评论