MKULTRON
Member
Posted 1 year ago #
I want my homepage to pull all the posts by the admin and I have two other pages to pull only specific posts from those authors.
I thought I may be able to do this just by appending something in the querystring eg ?author=1 - can't remember exactly but I got it working for the main page. Problem came when I tried to add this to the URL at the end of my custom template pages for the other authors, it'd put in an extra slash and bring up a 404. I've tried a bit of logic instead to bring up specific authors posts but these give me blank pages.
Any ideas? Would be much appreciated.
Thanks
MK
try it with a query posts before the loop
<?php
// The Query
query_posts( 'author=123' ); // author ID
// The Loop
while ( have_posts() ) : the_post();
// rest of loop
?>
MKULTRON
Member
Posted 1 year ago #
That works great, thank you! Have it set up like this:
<?php query_posts( 'posts_per_page=3 && author=1' ); ?>
Another problem i didn't realise before, but my "Newer" / "Older" links don't appear to be working, have them set up like:
<div class="pagination">
<li class="older"><?Php previous_posts_link('Older') ?>
<li class="newer"><?php next_posts_link('Newer') ?>
</div>
Any ideas? Thanks so much for your help
MK
try it with this:
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts( 'posts_per_page=3&author=1&paged='.$paged );
?>
Something along the same lines is this, which basically shows posts belonging to administrators (you might have more than one admin).
<?php
if (have_posts()) : while (have_posts()) : the_post();
global $authordata;
$user = new WP_User( $authordata->ID );
if ( !empty( $user->roles ) && is_array( $user->roles ) ) {
if ( in_array('administrator', $user->roles) )
continue;
}
// ...rest of loop code as usual
?>