Support » Miscellaneous » Query special post in author.php
8 years, 8 months ago
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.
$myposts = get_posts('category=40');
foreach($myposts as $post) :
<li><a>"><?php the_title(); ?></a></li>
<?php endforeach; ?>
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?
view profile here: http://www.ci-jou.de/?author=1
$author = get_userdata(get_query_var('author'));
$mypost = new WP_Query('showposts=1&cat=40&author=' . $author->ID);
if($mypost) : $mypost->the_post();
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endif; ?>
Kafkaesqui, thank you very much, it works!
8 years, 6 months ago
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.