• Resolved jmwhite19

    (@jmwhite19)


    I updated WordPress to 3.4 on my localhost environment this morning and found it broke my pagination setup I have for a certain theme I developed.

    Basically for the index.php I have the specific pagination setup of one article per page. For archives and everything else the standard WordPress settings are used. This was working in 3.3.2 but since upgrading to 3.4 the pagination setup for the index.php was broken.

    Here is the code I’m using. I’m aware that it maybe a hackish type solution so Im open to suggestion on how to improve it/get it working in 3.4.

    <?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts('posts_per_page=1&paged=' . $paged);
    
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>			
    
    <!--The post -->
    
    <?php endwhile; ?>
    
    <?php else : ?>
    
    <h2>Not Found</h2>
    
    <?php endif; ?>
    ?>
Viewing 8 replies - 16 through 23 (of 23 total)
  • Hello,

    Here is my product listing code
    <?php
    global $posts,$Product;
    $temp = $wp_query; $wp_query= null;
    $wp_query = new WP_Query(‘posts_per_page=’.$limit.’&post_type=products&paged=’ . $paged);
    if($wp_query->have_posts())
    {
    ?>
    <?php _e(‘Switch View’);?>
    <ul style=”display: block;” class=”display <?php echo $General->all_product_listing_format();?> category_list”>
    <?php
    while($wp_query->have_posts())
    {
    $wp_query->the_post();
    $Product->product_listing_li($post);
    }
    ?>

    <?php } ?>

    with this code pagination not work
    what is wrong in this can anybody solve this issue

    Thanks

    The solution above didnt work for me. Page 2 works fine, not 3 4 5 etc

    fixed by adding this to functions.php

    just change “CUSTOM POST TYPE HERE” with your post type. example: post, events, or gallery

    function my_query_for_homepage( $query ) {
    if( $query->is_main_query() && $query->is_home() ) {
    $query->set( ‘post_type’, array( ‘CUSTOM POST TYPE HERE’ ) );
    }
    }
    add_action( ‘pre_get_posts’, ‘my_query_for_homepage’ );

    this code solved the problem for me only for the homepage index, in categories and tags still the same problem, did you check the tags and categories ?

    then just add
    $query->set( ‘post_type’, array( ‘CUSTOM POST TYPE HERE’ , ‘tag’, ‘category’ ) );

    @ Alex – brilliant. Thanks for that.

    After upgrading to WP 3.4 a template I use to display all posts in an archive list format stopped working. Any tips?

    <?php get_header(); ?>
    <?php
    /*
    Template Name: All posts
    */
    ?>
    <?php
    $debut = 0; //The first article to be displayed
    ?>
    <?php while(have_posts()) : the_post(); ?>
    <h2><?php the_title(); ?></h2>
    <ul>
    <?php
    $myposts = get_posts('numberposts=-1&offset=$debut');
    foreach($myposts as $post) :
    ?>
    <li><?php the_time('d/m/y') ?>: <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    <?php endforeach; ?>
    </ul>
    
    <?php get_footer(); ?>
    <?php endwhile; ?>
    Moderator keesiemeijer

    (@keesiemeijer)

Viewing 8 replies - 16 through 23 (of 23 total)
  • The topic ‘WordPress 3.4 broke my paginaton setup’ is closed to new replies.