• Resolved estevanix

    (@estevanix)


    Hey,

    I’m using custom post types, but when using:

    <?php $loop = new WP_Query( array( 'post_type' => 'Post-Type_Name') );?>

    PageNavi doesn’t show. I’ve found the solution for normal posts:

    <?php
      $temp = $wp_query;
      $wp_query= null;
      $wp_query = new WP_Query('paged=' . $paged);
      while ($wp_query->have_posts()) : $wp_query->the_post();
    ?>

    But how to implement that for Custom Types?

    Thanks a lot,

Viewing 8 replies - 1 through 8 (of 8 total)
  • <?php
      $temp = $wp_query;
      $wp_query= null;
      $paged = get_query_var('paged') ? get_query_var('paged') : 1;
      $wp_query = new WP_Query(array('post_type' => 'Post-Type_Name',
                                     'paged' => $paged,
                                     'post_per_page' => 10)
                               );
      while ($wp_query->have_posts()) : $wp_query->the_post();
    ?>
    Thread Starter estevanix

    (@estevanix)

    Hey, Thanks a lot!
    Works perfectly!

    Just for the record, the final code:

    <?php
      $paged = get_query_var('paged') ? get_query_var('paged') : 1;
      $wp_query = new WP_Query(array('post_type' => 'Post-Type_Name',
                                     'paged' => $paged,
                                     'post_per_page' => 10)
                               );
      while ($wp_query->have_posts()) : $wp_query->the_post();
    ?>

    Thanks for this, was looking for exactly the same thing!

    I use a static landing page for the site, blog located on /blog/ and my custom post type located at /Rewrite-Slug/Post-Type_Name/ with posts located at /Rewrite-Slug/Post-Type_Name/%postname%/

    The code above worked great for me and now I have pagination printing on the custom post type index page. However navigating to “older entries” with the pagination returns 404 on /Rewrite-Slug/Post-Type_Name/page/2/

    I’ve tried removing the rewrite slug but no change?

    Any ideas would be greatly appreciated?

    Hey paulmitchellkelly!

    All you need to do is go to your permalinks page, change the structure back to the default, save, change it back to what you want it to be, save again and everything should work just fine!

    Worked for me using the method above.

    Good luck!

    LeoStorch

    (@leostorch)

    Hi, I’m with the same problem as paumitchellkelly…

    My WP is on the root of my domain, I’m using a custom post type and I followed all hierarchy of wp themes, but the Pagenavi isn’t working ok with CATEGORY.

    https://www.domain.com/CATEGORY BASE NAME/2006/ – Works ok, all the posts appears with the pagination, but when I click to move to another page, for example: https://www.domain.com/CATEGORY BASE NAME/2006/page/2/ , It returns 404!

    I’ve alread tried to change the permalinks back to default and save but the problem remains.

    CATEGORY.php

    $CatName = single_cat_title(”,false);
    $cat_id=get_cat_id($CatName);
    $paged = get_query_var(‘paged’) ? get_query_var(‘paged’) : 1;
    $count=1; query_posts(‘cat=’.$cat_id.’&post_type=eventos&paged=’.$paged.’&post_per_page=10′);?>

    PS: Pagenavi is working perfect in with taxonomy, but I have similar problems with the SEARCH REASULTS: https://www.domain.com/page/3/?s=keyword

    Any ideas what’s wrong? Thanks!

    I’m having the same problem as LeoStorch. Updating permalink structure does make pagination work perfectly, but this way all the other links (e.g. permalinks of posts) are messed up. Isn’t there any way to make them work at the same time?

    having same issue as above on category.php templates

    I’m a little baffled by this because the behavior I’ve found between WP native pagination, the WP-paginate plugin and now this plugin is IDENTICAL. I get the same query results appearing on all pages no matter what hacks and tricks I try (I’ve tried many).

    Perhaps I’m missing something bleedingly obvious. My code

    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $args = array(
    	'category_name' => 'products',
    	'orderby' => 'title',
    	'order' => 'ASC',
    	'posts_per_page' => '10',
    	'paged' => $paged
    );
    
    $wp_query = new WP_Query( $args );
    
    	if ( $wp_query->have_posts() ) {
    
    		while ( $wp_query->have_posts() ) : $wp_query->the_post();
    		//Do stuff
    		endwhile; // end of the loop.
    
    	wp_pagenavi( array( 'query' => $wp_query ) );
    	wp_reset_postdata();
    	}

    This is direct from the pagenavi instructions and it’s just as problematic as everything else I’ve tried. Somebody tell me I’m missing something.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘WP-PageNavi and Custom post Types’ is closed to new replies.