• Resolved Fanaticweb

    (@fanaticweb)


    Hello everyone,
    I noticed that since WP 5.7.1 the query posts targeting the author is now displaying the posts of all authors on the Author’s page, not sure if this is possibly linked to a plugin conflict or the WP core files, but one thing for sure, when compared to a WP 5.7 using the same theme and plugins, this issue is not present.

    Has there been a change in the way the custom posts and regular posts are pulled?

    This is the code that pulls custom posts by the Contributors and the WP native blog posts usually posted by the Admin:

    
    <!-- pull custom taxonomy posts -->
    <?php query_posts( array( 'post_type' => APP_POST_TYPE, 'author' => $curauth->ID, 'paged' => $paged ) ); ?>
    <?php get_template_part( 'loop', 'ad_listing' ); ?>
    
    <!-- pull blogy posts -->
    <?php if ( $author_posts_count ) { ?>
    <?php query_posts( array( 'post_type' => 'post', 'author' => $curauth->ID, 'paged' => $paged ) ); ?>
    <?php get_template_part( 'loop' ); ?>
    <?php } ?>
    

    If no changes should be affecting the code above, I will look into other sections of the theme to see what could be the root cause, but I would appreciate your feedback in case there’s an issue.

    Thank you.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Make sure that you’ve given the variable $curauth a useful value, for instance by using the following lines inside the loop:

    <?php 
    $curauth = (isset($_GET['author_name'])) ? get_user_by('slug', $author_name) : get_userdata(intval($author));
    ?>

    (Additional comment: I’m not sure this line would be optimal or even working. I just grabbed it from a really old Codex page.)

    Thread Starter Fanaticweb

    (@fanaticweb)

    Hi Tor-Bjorn, your code actually worked, I added it in the Author.php file and now things are back to normal, we only see the Author’s listings and posts when visiting their profile, I’m just puzzled as to why all of the sudden this extra code was needed considering it’s working fine on older WP versions.

    Thank you so much for your quick help by the way.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Query posts for Author shows posts of all authors’ is closed to new replies.