Link next_posts_link to a different template?
-
I’m using a custom template (home.php) for my home page. I have it displaying the page content for the homepage, and under that, a query for 1 post, to show the most recent post.
The homepage URL is the site root, not a template URL: https://pugix.com/synth/
I’d like to create a link to “more recent posts” which uses next_posts_link (as this is not a single-post-view page.)
This link loads the same home.php template, which doesn’t do exactly the job I’d like: 1. show excerpts not content, 2. leave out the “most recent activity” homepage post.
I could be happy with the home.php template if I could include some conditionals that check whether the url is a /page/[number and thereby hide the second part of the page.
hmm, would is_front_page() work? (I’ll try that)
Here’s what home.php looks like:
<?php /* Template Name: Home */ ?> <?php get_header(); ?> <div id="content-wrap"><div id="content"> <?php get_sidebar(); ?> <div id="main"> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <div class="post"> <h2 id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h2> <?php the_content(__('(more...)')); ?> <?php link_pages('<p><strong>Pages:</strong> ', '</p>', 'number'); ?> </div> <?php endwhile; endif; ?> <?php edit_post_link('Edit this entry.', '<p>', '</p>'); ?> <?php query_posts('showposts=1'); if (have_posts()) : while (have_posts()) : the_post(); ?> <h3>My most recent activity:</h3> <div class="navigation"> <div class="align-left"><?php next_posts_link('« More recent posts', '0'); ?></div> </div> <div class="post"> <h2 id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h2> <?php the_content(__('(more...)')); ?> <?php link_pages('<p><strong>Pages:</strong> ', '</p>', 'number'); ?> </div> <!-- Closes post --> <div class="navigation"> <div class="align-left"><?php next_posts_link('« More recent posts', '0'); ?></div> </div> <?php endwhile; endif; ?> <?php edit_post_link('Edit this entry.', '<p>', '</p>'); ?> </div> <!-- End main --> </div></div> <!-- end content and content-wrap --> <?php get_footer(); ?>
- The topic ‘Link next_posts_link to a different template?’ is closed to new replies.