admin管理员组

文章数量:1305115

I’m doing a site where all the posts are set to have a future date, and are published via a WP_Query. I know that this is somewhat going against the whole idea of how future-scheduled posts work, but that’s how this site has been set up.

As part of the site, I want to be able to have author pages for each post author, showing the posts that they have written — the fairly standard author.php type of archive.

At the moment, a standard loop won’t show the author’s posts, because they’re all dated in the future. So I’m trying to set up another WP_Query that will show all the posts by a given author. Here’s what I just tried to use:

<?php /* begin wp_query */ 
    $the_query = new WP_Query( 
        array(
            'category_name' => 'events', 
            'post_status' => array(future, publish),
            'author' => $curauth->ID
            )
        ); 
        
        if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?>

<p>Event: <strong><?php the_title(); ?></strong></p>

<?php endwhile; wp_reset_postdata(); else : __('Nope'); endif; /* end wp_query */ ?>

However, the problem here is that this is outputting a list of every single post on the whole site, by all authors — not just by whichever author’s page I’m on.

So — how do I get it to just show the posts by the given author, and not every post at once?

Thanks...

本文标签: