• Using the latest WordPress 3.4.2 installation and just realized that pagination is broke on my page –> metropochris.com

    I’ve searched the forums and have tried multiple solutions to no avail.

    These include…

    1. Installing WP No Category Base plugin

    2. Adding this code to my functions.php…

    function my_query_for_homepage( $query ) {
    if( $query->is_main_query() && $query->is_home() ) {
    $query->set( 'post_type', array( 'posts' ) );
    }
    }
    add_action( 'pre_get_posts', 'my_query_for_homepage' );

    3. Adding this code to my functions.php…

    function my_post_queries( $query ) {
      // not an admin page and it is the main query
      if (!is_admin() && $query->is_main_query()){
        if(is_home()){
          $query->set('posts_per_page', 1);
        }
      }
    }
    add_action( 'pre_get_posts', 'my_post_queries' );

    4. Adding this code to my functions.php…

    if ( ! function_exists( 'ucc_add_cpts_to_pre_get_posts' ) ) { function ucc_add_cpts_to_pre_get_posts( $query ) { if ( $query->is_main_query() && ! is_post_type_archive() && ! is_archive() && ! is_search() && ! is_singular() && ! is_404() ) { $my_post_type = get_query_var( 'post_type' ); if ( empty( $my_post_type ) ) { $query->set('post_type', 'video'); } } } } add_action( 'pre_get_posts', 'ucc_add_cpts_to_pre_get_posts' );
    
    <?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $loop = new WP_Query(array('post_type' => 'name_of_post_type','paged'=>$paged));
    ?>

    I tried these all independently, didn’t just stack code on top of code in my functions.php.

    If you’re curious my functions.php file in full for my custom theme is as follows…

    [540 lines of code moderated, Please use a pastebin.]

    Perhaps someone can lend me some insight. Thanks!

Viewing 1 replies (of 1 total)
  • Thread Starter Chris Perez

    (@sforscarlet)

    Upping and hoping someone can give me another suggestion to resolve the broken pagination in WordPress 3.4 for custom themes.

Viewing 1 replies (of 1 total)
  • The topic ‘Can't fix pagination in WordPress 3.4’ is closed to new replies.