0

I'm reasonably new to WordPress and I believe I am missing something conceptual here.

I have assigned a static post to be my front page. My front-page.php template begins with a standard loop:

<?php if (have_posts()) : ?>            
    <?php while ( have_posts() ) : the_post(); ?>
            <h2><?php the_title()?></h2>
            <?php the_content(__('Continue Reading'))?>
    <?php endwhile; ?>
    <?php wp_reset_postdata();?>    
<?php else : ?>
    <h2 class="center">Not Found</h2>
    <p class="center"><?php _e("Empty Text Here."); ?></p>
<?php endif; ?> 

This successfully outputs the content of my post. Great.

Now I am attempting to insert a second loop below this that will output a finite list of other posts followed by a pager. The pager shows up and when it is clicked the page reloads as expected, but the content remains unchanged. Here is my second loop?

<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args=array(
    'paged'             =>  $paged,
    'posts_per_page'    =>  2, 
    'post_type'         => 'type_here'
);
$wp_query = new WP_Query($args);?>
<?php if ( $wp_query->have_posts() ) :?>
    <?php while ($wp_query->have_posts() ) : $wp_query->the_post(); ?>  
        <h3><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3>
    <?php endwhile;?>
    <?php wp_pagenavi(); ?>
    <?php wp_reset_query(); ?>
<?php else: ?>
    <?php echo 'Empty Text Here';?>
<?php endif;?>

My taxonomy pages all paginate perfectly so I'm thinking my mistake is programmatically subtle or conceptually flagrant. Is it not possible for a post template to feature a secondary loop with its own pagination?

Given that pagers generate a loop agnostic URL I am guessing that WP assumes that only the original loop qualifies for paging?

http://mysite.com/page/2/

Thanks for your help!

1

According with the Wodrdpress Codex: Pagination on static front page uses the page query variable, not the paged variable. See the WP_Query for details.

| improve this answer | |
  • I see it now. "Static front pages are not intended to be paged." I wonder how one is supposed to provide a pagable front with a page title and intro text that can be modified without touching PHP files? I guess that is for another day. Thanks. – Ecksley Feb 24 '14 at 7:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.