Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to draw a conclusion of posts in the profile


  • galiulinr
    Participant

    @galiulinr

    I added the following code in your theme function:

    
    function get_related_author_posts() {
        global $authordata, $post;
        $authors_posts = get_posts( array( 'author' => $authordata->ID, 'post__not_in' => array( $post->ID ), 'posts_per_page' => 5 ) );
        foreach ( $authors_posts as $authors_post ) {
            $output .= '<l i>< a>ID ) . '">' . apply_filters( 'the_title', $authors_post->post_title, $authors_post->ID ) . '</ a></l i>';
        }
        return $output;
    }
    

    On page user-profile.php, I put the following code:
    <?php echo get_related_author_posts(); ?>

    It shows 5 posts, but I want to show only the for profile author of this posts. Now it shows all the user profiles.Each author should have a list of posts in the profile. Tell me how to do it.

Viewing 1 replies (of 1 total)

  • galiulinr
    Participant

    @galiulinr

    Here’s the code works for me:

    <?php $curauth = (isset($_GET['author_name'])) ? get_user_by('slug', $author_name) : get_userdata(intval($author)); ?>
    <!-- The Loop -->
        <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
            <l i>
                <a hr ef="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>">
                <?php the_title(); ?></ a>,
                <?php the_time('d M Y'); ?> in <?php the_category('&');?>
            </l i>
        <?php endwhile; else: ?>
            < p><?php _e('No posts by this author.'); ?></ p>
        <?php endif; ?>
    <!-- End Loop --> 
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.
Skip to toolbar