• Resolved kasperbs

    (@kasperbs)


    Hi,
    I have a very specific query. I’m working on this for a client so would be willing to pay anyone who can help me. My email is kasprbs [at] gmail [dot] com.

    I need to create a template page that shows all the posts written by the author of the page using this template.

    I will create 20 single pages which will all use this template. Then I will simply change the author of each page and then the loop should pull all posts of this author when viewing it.

    Here’s how far I’ve come with the loop.

    <?php
    	$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    	$page_author = ;
    	query_posts("author_name=$page_author&paged=$paged");
    
    	if (have_posts()) : ?>

Viewing 2 replies - 1 through 2 (of 2 total)
  • kasperbs – why not create one template – author.php – which would call the same things – author avatars, author posts, author info, etc.? http://codex.ww.wp.xz.cn/Author_Templates

    Thread Starter kasperbs

    (@kasperbs)

    Hi,
    Thanks for your suggestion. I don’t think it would work because basically the authors act as categories. Anyway I just came back to let you know that I managed to find a solution.

    Here’s the template code I ended up with if anyone needs the same.

    <?php
    /*
    Template Name: Netvaerk News
    */
    ?>
    <?php
    get_header(); ?>
    	<div class="span-16 last">
    	<div class="content">
    
    	<?php if (have_posts()) : ?>
    
    		<?php while (have_posts()) : the_post(); ?>
    
    			<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
    				<h1 class="post-title">Nyheder & Aktiviteter</h1>
    				<div class="entry">
    					<?php $page_author = get_the_author();?>
    				</div>
    			</div>
    
    	<?php endwhile; endif; ?>
    
    	<?php
    		$temp = $wp_query;
    		$wp_query= null;
    		$wp_query = new WP_Query();
    		$wp_query->query('showposts=5&cat=383&author_name=' . $page_author . '&paged=' .$paged);
    	?>
    
    	<?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
    		<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
    				<h1 class="post-title"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a><?php edit_post_link(' - EDIT THIS', '<span>', '</span>'); ?></h1>
    				<div class="post-meta"><?php the_time('j. F, Y') ?></div>
    				<div class="entry">
    					<?php the_excerpt(); ?>
    					<p style="margin-top:-1em;"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">&raquo; L&aelig;s mere...</a></p>
    				</div>
    		</div>
    	<?php endwhile; ?>
    
    		<div class="navigation">
    			<div class="alignleft"><?php next_posts_link('&laquo; &AElig;ldre') ?></div>
    			<div class="alignright"><?php previous_posts_link('Nyere &raquo;') ?></div>
    		</div>
    
    	</div>
    	</div><!-- end of span-17 -->
    
    <?php get_footer(); ?>
Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Show posts based on page-author’ is closed to new replies.