my site have multiple authors. I need to show all type of author posts in author page that if visitors can see all posts of author when visitied his profile page.

this code

    <?php get_header(); ?>

<!-- Show custom post type posts from the author -->
<?php global $wp_query;
query_posts( array(
    'post_type' => 'sikayet' ,
    'author' => get_queried_object_id(), 
    'showposts' => 10 )
); ?>

<?php if ( have_posts() ): ?>
    <h3>SIKAYETKLER <?php echo $curauth->first_name; ?>:</h3>
    <?php while ( have_posts() ) : the_post(); ?>
        <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>">
<?php the_title(); ?></a></p>
    <?php endwhile; ?>
<?php else: ?>
    <p><?php _e('User has no custom posts'); ?></p>
<?php endif; ?>

<?php get_footer(); ?>
  • You should use pre_get_posts filter to change query parameters (like post type, number of posts per page, etc.) insted create new WP_Query. – nmr Jun 4 '19 at 13:21

If you use WordPress author template to show user posts ( example.com/author/{user_name} ) the best solution will be to change the main query via the pre_get_posts filter hook.

function se339534_author_any_post_types $query ) {

    // apply changes only for author archive page
    if ( ! is_author() || ! $query->is_main_query() )

    $query->set('post_type', 'any');
add_action( 'pre_get_posts', 'se339534_author_any_post_types' );
  • not worked.. i just need to show users other posts of author – Ramin Mahmudov Jun 4 '19 at 10:46
  • What is the "author page"? I understand this is not the default template provided by WordPress and the address is not /author/{user_name}. – nmr Jun 4 '19 at 11:23
  • its defaut author template.. provided by WordPress... – Ramin Mahmudov Jun 4 '19 at 11:25
  • So even if you add this code to the functions.php file, you still see only the list of "blog" posts? – nmr Jun 4 '19 at 11:30
  • probleblem is that.. author.php crated by me.. and this in page there are information and picture of author.. and i also want to display posts publised by this author that visitor can see this information. when they entered author.php – Ramin Mahmudov Jun 4 '19 at 11:32

I'm not sure if this is what you mean but this Wordpress function can display list of authors:

wp_list_authors( $args );


You can use this one to display the posts of an author: https://codex.wordpress.org/Class_Reference/WP_Query#Author_Parameters

The author is the parameter.

  • thanks for you repy. but i want to show posts of author.. posts that written by author – Ramin Mahmudov Jun 4 '19 at 9:10
  • Just edited my answer. I'm so sorry I didn't understand the question quite well. How about that? – maryyyyyyy Jun 5 '19 at 0:56

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.