WordPress.org

Ready to get started?Download WordPress

Forums

3.4 pagination problem (4 posts)

  1. picuin
    Member
    Posted 1 year ago #

    my blog doesn't work since i upgraded it from WP 3.3.2 to 3.4.
    so previous/next_post_link is not working.

    This is the code i'm using for my index page:

    <?php
                     $args = array(
                           'post_type' => 'foto',
                           'posts_per_page' => 12,
                           'orderby' => 'post_date',
                           'order'=> 'DESC',
                           'post_status' => 'publish',
                           'paged' => (get_query_var('page')) ? get_query_var('page') : 1);
    
                                query_posts($args) ;?>
    
                                <?php while ( have_posts() ) : the_post(); ?>

    currently i changed posts_per_page to 30, so that every post can be seen.

    thx for ur help.

  2. keesiemeijer
    moderator
    Posted 1 year ago #

    try it without the query_posts in index.php and with this in your functions.php:

    function my_post_queries( $query ) {
      // not on admin pages and is the main query
      if (!is_admin() && $query->is_main_query()){
        if(is_home()){
          $query->set('posts_per_page', 12);
          $query->set('post_type', 'foto');
        }
      }
    }
    add_action( 'pre_get_posts', 'my_post_queries' );
  3. picuin
    Member
    Posted 1 year ago #

    thank u so much, it works.

  4. keesiemeijer
    moderator
    Posted 1 year ago #

    You're welcome. Im glad you got it resolved.

    read here why it works (a bit technical): http://developer.wordpress.com/2012/05/14/querying-posts-without-query_posts/

Topic Closed

This topic has been closed to new replies.

About this Topic