0

I've build a taxonomy that holds the categories of a custom post type. This is going to be used to create a sub-menu called categories that is a filter to generate all the custom post types that have the same category.

The menu works fine since it's able to call the category of news but the problem comes with pagination.

I'm calling:

<?php echo $mypod->pagination( array( 'type' => 'pagination' ) ); ?>

When I click on one of the paginate links this will send a $_GET parameter to the page URL.

example.com?p=2

For some reason, when I pass that parameter for pages, my categories menu suddenly disappears.

I'm using this to call my categories menu:

 if(isset($_GET['category'])){
  $get_category = $_GET['category'];
}


if($get_category):
  $params = array(
    'limit' => 2,
    'where' => "news_category.slug = '$get_category'",
  );
else:
  $params = array(
    'limit' => 2,
  );
endif;

$mypod = pods( 'news' );
$mypod->find( $params );

And this to print them

<?php
                $params = array(
                  'orderby' => 't.name DESC',
                  'limit' => 16
                );
                $category = pods('news_category',$params);
                $url = get_home_url()."/index.php/".get_page_uri($post);

                while ( $category->fetch() ) {
                  $url .= "?category=".$category->display('slug');
                  echo '<li>'."<a href=\"$url\">". $category->display( 'name' ) . '</a></li>';
                  $url = get_home_url()."/index.php/".get_page_uri($post);
                }
              ?>

Any help would be highly appreciated!

0

You can disable pagination per find() query in Pods by setting 'pagination' => false, I also suggest disabling search with 'search' => false. You can do this globally by setting these constants, which means you'll have to explicitly enable search or pagination on the queries you want them enabled on by setting 'pagination' => true or 'search' => true.

Here are the constants to control this globally, define them in your wp-config.php, or you can even define them in your functions.php file in your theme, but you might consider just setting them on the condition if ( ! is_admin() ):

define( 'PODS_GLOBAL_POD_PAGINATION', false ); // Disable pagination
define( 'PODS_GLOBAL_POD_SEARCH', false ); // Disable search

Pods::find() documentation

  • Great! Just mark this as the answer so your question can properly get closed :) – Scott Kingsley Clark Feb 20 '16 at 17:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.