Tsalagi
Member
Posted 2 years ago #
I'm testing a template trying to get the loop to show a list of pages the author has created using the_author_posts_link() and the number of pages the author has created using `the_author_posts()'. This is not working. I think that maybe this doesn't include pages only blog posts? Does anyone have a solution?
Thanks in advance
Doesn't seem to be an equivalent for pages, so i'd suggest using..
get_posts()
With some of the optional parameters, it may seem odd to use get_posts for pages instead of get_pages , but you'll get more control over get_posts, it's a little more flexible..
See here for examples / info:
http://codex.wordpress.org/Template_Tags/get_posts
However that page is somewhat out-dated, just see the query_posts page as a reference for supported args, they both operate same and use the same args.
http://codex.wordpress.org/Template_Tags/query_posts
Tsalagi
Member
Posted 2 years ago #
okay I'm narrowing this down but still need some pointers.
The code below lives in a file named author.php. I'm using a link as show above the_author_posts_link() in the page.php for content display. This show the author's name and when the author's name is clicked it opens the author.php page. Which has this code.`<?php
get_header();
?>
<div id="content" class="narrowcolumn">
<!-- This sets the $curauth variable -->
<?php
if(isset($_GET['author_name'])) :
$curauth = get_userdatabylogin($author_name);
else :
$curauth = get_userdata(intval($author));
endif;
?>
<h3>About: <?php echo $curauth->display_name; ?></h3>
<p>Website: user_url; ?>"><?php echo $curauth->user_url; ?></p>
<p>Profile: <?php echo $curauth->user_description; ?></p>
<h3>Posts by <?php echo $curauth->display_name; ?>:</h3>
</div>
<?php get_footer(); ?>`
This code is supposed to list all pages by the author of the orignial article but it displays "No posts by this author."
Where do I go from here?
Thanks
Sleepless and snowbound
Tsalagi
Member
Posted 2 years ago #
When posting long sections of code, please use a pastebin.
http://wordpress.pastebin.ca/
Would i be correct in assuming you initially followed the example here?
http://codex.wordpress.org/Author_Templates
Try adding this just after <?php get_header(); ?> ..
<?php
if(!$wp_query) global $wp_query;
query_posts( array_merge( array('post_type'=>'page') , $wp_query->query ) );
?>
You should then see pages instead of posts... it works in my test author template.. :)
Tsalagi
Member
Posted 2 years ago #
I wasn't aware of the pastebin. Thanks for the info.
I'll look further into that query. I appreciate your time