Wordpress and Webdesign Forum go41 » WordPress Code Snippets

  1. adamwork
    Member

    Hi all

    So here is my situation.

    I have author.php, which shows a list of latest posts from that author. On the top right hand corner, I then have information about the author (Biog, Name etc).

    Underneath that, I want to display posts from a different category. BUT - the category changes depending on the author.

    How can I go about setting that up?

    Many thanks for your help/advice.

    Adam

    Posted 1 year ago #
  2. I guess you query for a certain category and want to show posts of the current author only?

    Let's say you query for a category like this:

    query_posts('cat=4');

    to get this query display only posts of the author you just show, you can get the current author ID like this:

    $authid=$curauth->ID;

    and add in the query you use: &author=$authid

    the code getting the current author and looking for his posts in category 4 would look like this:

    <?php
    $authid=$curauth->ID;
    query_posts('cat=4&author=$authid');
    ?>
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    
    title and content here
    
    <?php endwhile; else: ?>
    
    <?php endif; ?>
    
    <?php //Reset Query
    wp_reset_query();
    ?>

    did not try, you are my 'beta tester' ;-)

    Posted 1 year ago #
  3. adamwork
    Member

    Hi masteradmin

    The main page already shows the post of the author.

    I want to display posts from a different category in the sidebar. The category in the sidebar will be different, depending on the author.

    Thanks
    adam

    Posted 1 year ago #

RSS feed for this topic

Reply

You must log in to post.

Join us! or log in (lost password?):