logo

$10
404 error on next_posts_link on category page

Hi,

I get an 404 error - not found page when i click on the next_post_link or previous post link on a category page.

Link: http://www.nono.be/huisstijlen-en-drukwerk/
Error page: http://www.nono.be/huisstijlen-en-drukwerk/page/2/

See the code below

Any way how I can fix this?

Thanks for the quick response.

Gr.
Filip



<?php
/*
Template Name: Home
*/
?>
<?php get_header(); ?>

<div id="content">
<div class="row" style="width:950px; margin:0 auto">
<div class="column-left" style="border:none">
<h2><img src="<?php bloginfo('template_directory'); ?>/img/tit-huisstijlen-en-drukwerk.png" alt="Nono blogt"/></h2>
<?php
$my_id = 290;
$post_id_290 = get_post($my_id);
$content = $post_id_290->post_content;
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]>', $content);
echo $content;
?>
</div>
<div class="column-right">
<?php
$postslist = get_posts('numberposts=4&order=DESC&orderby=date&category=11');
foreach ($postslist as $post) :
setup_postdata($post);
?>
<div class="post">
<div class="square-info">
<div class="v-outer">
<div class="v-middle">
<div class="v-inner"> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
<h2>
<?php the_title(); ?>
</h2>
<p>
<?php $key="Label"; echo get_post_meta($post->ID, $key, true); ?>
</p>
</a> </div>
</div>
</div>
</div>
<div class="square-img"> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
<?php the_post_thumbnail(); ?>
</a> </div>
</div>
<?php endforeach; ?>
</div>
<div class="clear"></div>
</div>
<hr class="line-horizontal-001">
<div class="row" style="padding-top: 15px">
<div class="archive">
<h2><img src="<?php bloginfo('template_directory'); ?>/img/tit-ontdek-onze-portfolio.png" /></h2>
<?php

$row = 1;

?>
<?php while (have_posts()) : the_post(); ?>
<?php

$postCount=$postCount+1;

?>
<div <?php post_class() ?>>
<?php

if($row&1){

?>
<div class="square-info">
<div class="v-outer">
<div class="v-middle">
<div class="v-inner"> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
<h2 id="post-<?php the_ID(); ?>">
<?php the_title(); ?>
</h2>
<p>
<?php $key="Label"; echo get_post_meta($post->ID, $key, true); ?>
</p>
</a> </div>
</div>
</div>
</div>
<div class="img"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
<?php the_post_thumbnail(); ?>
</a></div>
<?php

} else {

?>
<div class="img" style="margin-right:10px"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
<?php the_post_thumbnail(); ?>
</a></div>
<div class="square-info" style="margin-right:0px">
<div class="v-outer">
<div class="v-middle">
<div class="v-inner"> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
<h2 id="post-<?php the_ID(); ?>">
<?php the_title(); ?>
</h2>
<p>
<?php $key="Label"; echo get_post_meta($post->ID, $key, true); ?>
</p>
</a> </div>
</div>
</div>
</div>
<?php

}

?>
</div>
<?php

if (($postCount % 4) == 0 ) {
$row = $row+1;
$postCount=0;

}

?>
<?php endwhile; ?>
<div class="clear"></div>
<div class="next-post-link">
<?php next_posts_link('Vorige') ?>
</div>
<div class="previous-post-link">
<?php previous_posts_link('Volgende') ?>
</div>
</div>
<div class="clear"></div>
<hr class="line-horizontal-002">
</div>
</div>
<div class="clear"></div>
</div>
<?php get_footer(); ?>


Filip Van Reeth | 12/27/10 at 3:25am | Edit


(2) Possible Answers Submitted...

  • avatar
    Last edited:
    12/27/10
    7:18am
    Michael Fields says:

    Hi. IMHO it is poor form to use a page template to display multiple posts. Category templates are designed to accomplish exactly what you need without producing errors such as you are experiencing here. I would start by saving this code as category-11.php and re-working it. previous_posts_link() and previous_posts_link() are not designed to work in this context

    • 12/27/10 4:51am

      Filip Van Reeth says:

      Hmm,

      Thanks for the information.
      I use the category.php to check which category it is and redirect to the right category design template.


      <?php
      if ( is_category( array ( 11 ) ) ) {
      include(TEMPLATEPATH . '/category-01.php');
      }

      elseif ( is_category( array ( 12 ) ) ) {
      include(TEMPLATEPATH . '/category-02.php');
      }

      else {
      include(TEMPLATEPATH . '/category-default.php');
      }
      ?>



      How do you think I can fix this?
      Does renaming it will solve the problem?

      Thank for the quick response ;-)

    • 12/27/10 5:01am

      Michael Fields says:

      No problem. Actually, there is no need to have a file like this at all, it may actually cause problems in the future... WordPress handles all of this for you. I would suggest reading over the template hierarchy Codex page mainly the category template section: http://codex.wordpress.org/Template_Hierarchy#Category_display

      As for you original question, if you save the page template you posted above (don't forget to delete the template comment from the top) and save it as category-11.php WordPress will automatically include it when category 11 is queried for.

    • 12/27/10 5:11am

      Filip Van Reeth says:

      Hi,

      Renamed it to category-11 & category-12.php.
      Removed the category.php file.
      Removed the template comment.

      Still get the error? Or is there something wrong with the code?
      Thanks for the help.

      Gr.

    • 12/27/10 5:19am

      Michael Fields says:

      Try these, They work fine for me:
      http://www.nono.be/category/huisstijlen-en-drukwerk/
      http://www.nono.be/category/huisstijlen-en-drukwerk/page/2/

    • 12/27/10 6:45am

      Filip Van Reeth says:

      Thx.
      Is there any way to remove the /category/ in the url?
      Just so it says www.nono.be/huisstijlen-en-drukwerk

    • 12/27/10 6:45am

      Filip Van Reeth says:

      Thx.
      Is there any way to remove the /category/ in the url?
      Just so it says www.nono.be/huisstijlen-en-drukwerk

    • 12/27/10 6:55am

      Michael Fields says:

      I would suggest that you try this plugin:

      http://wordpress.org/extend/plugins/wp-htaccess-control/

      It is compatible with current version of WordPress

    • 12/27/10 6:56am

      Filip Van Reeth says:

      Sebastien also mentioned a plugin that works.
      I asked him if there is any way to do this native without a plugin?
      Just for information.

    • 12/27/10 6:57am

      Michael Fields says:

      Not without a plugin or similar code.

    • 12/27/10 6:58am

      Filip Van Reeth says:

      Ok, thanks for the information.
      I'm just waiting for the answer of Sebastien.
      Then I will select a winner ;-)

  • avatar
    Last edited:
    12/27/10
    7:18am
    Sébastien | French WordpressDesigner says:

    Filip,

    1-in your file, erase this



    <?php

    /*

    Template Name: Home

    */

    ?>

    2-save your file as category-11.php

    3-not delete category.php
    4-in category.php erase :
    <?php

    if ( is_category( array ( 11 ) ) ) {

    include(TEMPLATEPATH . '/category-01.php');

    }



    elseif ( is_category( array ( 12 ) ) ) {

    include(TEMPLATEPATH . '/category-02.php');

    }



    else {

    include(TEMPLATEPATH . '/category-default.php');

    }

    ?>



    the content of this page http://www.nono.be/huisstijlen-en-drukwerk/ is now generate by category-11.php, so if you want see this page you must use the url of the category 11 which is probably : http://www.nono.be/category/huisstijlen-en-drukwerk/

    Previous versions of this answer: 12/27/10 at 6:15am | 12/27/10 at 6:17am | 12/27/10 at 6:17am

    • 12/27/10 6:45am

      Filip Van Reeth says:

      Thx.
      Is there any way to remove the /category/ in the url?
      Just so it says www.nono.be/huisstijlen-en-drukwerk

    • 12/27/10 6:49am

      Sébastien | French WordpressDesigner says:

      you can use this plugin : http://wordpress.org/extend/plugins/wp-no-category-base/

    • 12/27/10 6:55am

      Filip Van Reeth says:

      Thx.
      Works like a charm.
      Do you know any way to do this native (without a plugin)?
      Just for information ;-)

    • 12/27/10 7:17am

      Sébastien | French WordpressDesigner says:

      i think there is no way

This question has expired.





Current status of this question: Completed