Forums

[resolved] recent posts from author (1 post)

  1. Misterpayne112
    Member
    Posted 2 years ago #

    i received help before with this code. the code below shows the last 10 posts in that particular category on a single post page. i am looking to modify this query to give me the last 10 post by the author of the single page post. can anyone help me change the code to get my desired result?

    <?php
    if (is_single( )) {
    $post_ID = $wp_query->posts[0]->ID;
    $all_cats_of_post = get_the_category($post_ID);
    $first_cat_ID = $all_cats_of_post[0]->cat_ID;
    $first_cat_name = $all_cats_of_post[0]->cat_name;
    $first_cat_parent = $all_cats_of_post[0]->category_parent;
    ?>
    <div id="category-posts-<?php echo $first_cat_ID; ?>" class="widget widget_recent_entries">
    <div class="widget-title"><b>Similar/Related Articles:</b></div>
    <div class="widget-content">
    <table width=100%><tr><td width=1%></td><td>
    <?php global $post; $cat_posts = get_posts('numberposts=10&category='.$first_cat_parent);
    foreach($cat_posts as $post) : ?>
        <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li><br />
    <?php endforeach; ?>
    </div>
    </div>
    <?php } ?>
    </td></tr></table>

Topic Closed

This topic has been closed to new replies.

About this Topic