how to show all type of author posts in author page (SOLVED)

my site have multiple authors. I need to showall type of author posts in author page that if visitors can see all post

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(); ?>

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(); ?>
Share Improve this question edited Jun 4, 2019 at 13:15 Ramin Mahmudov asked Jun 4, 2019 at 6:16 Ramin MahmudovRamin Mahmudov 511 silver badge12 bronze badges 1
  • 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 Commented Jun 4, 2019 at 13:21
Add a comment  | 

2 Answers 2

Reset to default 3

If you use WordPress author template to show user posts ( example/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() )
        return;

    $query->set('post_type', 'any');
}
add_action( 'pre_get_posts', 'se339534_author_any_post_types' );

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

wp_list_authors( $args );

https://codex.wordpress/Function_Reference/wp_list_authors

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

The author is the parameter.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745437441a4627673.html

相关推荐

  • how to show all type of author posts in author page (SOLVED)

    my site have multiple authors. I need to showall type of author posts in author page that if visitors can see all post

    4小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信