0

I have this code that is displaying my last active authors. I also would like it to display WP administrators in this list. The code is:

$authors =  array();
$count = 0;
$args=array(
    'post_type' => 'post',
    'post_status' => 'publish',
    'posts_per_page' => -1,
    'caller_get_posts'=> 1
);
$my_query = null;
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) {
    echo '';
    while ($my_query->have_posts() && $count < 15) : $my_query->the_post();
        $author_id=$my_query->post->post_author;
        $user = new WP_User( $author_id );
        if ( !empty( $user->roles ) && is_array( $user->roles ) && in_array('contributor',$user->roles) ) {
            if (!in_array($author_id,$authors)) {
                echo '<div class="person">';

Where it says && in_array('contributor',$user->roles), I need to include 'administrator' as well. What would be the right way to put this in? I have tried a lot of things but then the PHP won't work.

  • change in_array('contributor',$user->roles) to (in_array('contributor',$user->roles) || in_array('administrator',$user->roles)) – Reigel Feb 5 '15 at 1:39
0

change in_array('contributor',$user->roles) to (in_array('contributor',$user->roles) || in_array('administrator',$user->roles))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.