Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

So the Next/Previuos on my index page is broken. It goes to page 2 but doesn't refresh the posts. It will work on my categories and it will work on my posts but it just won't work on the from page. Here's my code:

<?php get_header();?>
<?php include('from.php'); ?>
<div id="content">
<div id="content-main">
        <?php if ($posts) {
                if (get_settings('mistylook_asideid') != "")
                    $AsideId = get_settings('mistylook_asideid');
                function ml_hack($str)
                {
                    return preg_replace('|</ul>\s*<ul class="asides">|', '', $str);
                }
                ob_start('ml_hack');
                foreach($posts as $post)
                {
                    the_post();
                ?>
                <?php if ( in_category($AsideId) && !is_single() ) : ?>
                    <ul class="asides">
                        <li id="p<?php the_ID(); ?>">
                            <?php echo wptexturize($post->post_content); ?>
                            <br/>
                            <p class="postmetadata"><?php comments_popup_link('(0)', '(1)','(%)')?>  | <a href="<?php the_permalink(); ?>" title="<?php _e('Permalink:','ml');?> <?php echo wptexturize(strip_tags(stripslashes($post->post_title), '')); ?>" rel="bookmark">#</a> <?php edit_post_link(__('(edit)','ml')); ?></p>
                        </li>
                    </ul>
                <?php else: // If it's a regular post or a permalink page ?>
                <div id="post-<?php the_ID(); ?>" <?php if (function_exists('post_class')){ post_class(); } else { echo 'class="post"' ;} ?>>
        <div class="posttitle">
          <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php _e('Permanent Link to','ml');?> <?php the_title(); ?>"><?php the_title(); ?></a></h2>
                    <p class="post-info">            
            <?php the_time(__('M jS, Y','ml')) ?> <?php _e('by','ml');?> <?php the_author_posts_link() ?> <?php edit_post_link(__('Edit','ml'), '', ' | '); ?> </p>          
                </div>

                <div class="entry">
                    <?php the_content(__('Continue Reading &raquo;','ml')); ?>
                    <?php wp_link_pages(); ?>
                    <p><?php if (function_exists('the_tags')) the_tags(__('Tags: ','ml'), ', ', '<br/>'); ?> </p>
                </div>

                <p class="postmetadata"><?php _e('Posted in','ml');?> <?php the_category(', ') ?> | <?php comments_popup_link(__('No Comments &#187;','ml'), __('1 Comment &#187;','ml'), __('% Comments &#187;','ml'),'',__('Comments Off','ml')); ?></p>
                <?php comments_template(); ?>
            </div>
            <?php endif; // end if in category ?>
            <?php
                }
                 ob_end_flush();
            }
            else include_once(TEMPLATEPATH.'/notfound.php');
        ?>
        <p align="center"><?php posts_nav_link(' &#183; ', 'previous page', 'next page'); ?></p>
</div><!-- end id:content-main -->
<?php get_sidebar();?>
<?php get_footer();?>

I'm using a random theme called MistyLook. I've tried working with it but if I have to go to the core files then im stumped... Any suggestions?

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

I had the exact same problem a while ago on one of my themes. My problem was that the theme used query_post to filter out some posts. This caused the pagination to fail.

I think this was the code that solved it:

    <?php
         if ( is_home() ) {
            $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
            query_posts("cat=-19&paged=$paged");
         }
    ?>

cat=-19 was the category I wanted to remove. Try to just include it without cat=-19 if you want to include all categories.

The point of this code was to save the variable paged and include it again after I had made a custom query_posts so that WordPress knows what page the reader is on.

share|improve this answer
    
I think the point of the code was that using query_posts removes all standard included values of the standard query_post in WordPress. This code includes the query variabel again so that WordPress again can understand what page the user is currently on. –  Ole Henrik Skogstrøm Jan 12 '12 at 22:13
    
Ha! I'm querying only 1 category via query_posts. I'll have to play around with that code above to maybe try to fir my situation. –  Howdy_McGee Jan 12 '12 at 22:16
    
i think if you use the code above as is to get just one category out of the loop it would solve the problem. then all you need to change is the part "cat=(id of category)". Or if you wan to use the category slugg use "category=(slug of category)" –  Ole Henrik Skogstrøm Jan 12 '12 at 23:42
    
Did you find a solution to your problem? :) –  Ole Henrik Skogstrøm Jan 16 '12 at 23:21
    
:D Yes I did very much in part to your answer! Thank you! –  Howdy_McGee Jan 17 '12 at 0:17
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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