• In the author profile we habe all his posts as a list. Every author can have his own guestbook by writing a post in category guestbook. Now I want to query the guestbook outside the loop.

    I tried

    <ul>
    <?php
     global $post;
     $myposts = get_posts('category=40');
     foreach($myposts as $post) :
     setup_postdata($post);
     ?>
    <li><a>"><?php the_title(); ?></a></li>
     <?php endforeach; ?>
     </ul>

    but with this I get the guestbook-links of all authors in the profile of each author.

    How can I get only the guestbook-post of the current author in the current author’s profile?

    Thanks
    Rita

    view profile here: http://www.ci-jou.de/?author=1

Viewing 3 replies - 1 through 3 (of 3 total)
  • Try:

    <?php
    $author = get_userdata(get_query_var('author'));
    $mypost = new WP_Query('showposts=1&cat=40&author=' . $author->ID);
    if($mypost) : $mypost->the_post();
    ?>
    <ul>
    <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    </ul>
    <?php endif; ?>

    Thread Starter nickrita

    (@nickrita)

    Kafkaesqui, thank you very much, it works!

    Thread Starter nickrita

    (@nickrita)

    Hi, it’s me again.

    Is there any chance to get the contend AND the comments of the post together with the title? I tried and was able to get the contend, but not the comments.

    Thanks,
    Rita

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Query special post in author.php’ is closed to new replies.