Friday, August 26, 2022
HomeWordPress DevelopmentHow do I take away pagination from just a few Classes?

How do I take away pagination from just a few Classes?


I’ve website I am constructing that has a bunch of classes, however one class and its subcategories are particular. They’ve a complicated customized discipline for a Google Map location. I’ve the map with every thing on a class web page working, however when looping by means of the posts I clearly solely get the posts on the web page. So, for these archive pages for these classes, and solely these classes, I must take away pagination. I understand how to regulate pagination in capabilities.php and in WordPress setting, however I do not know the way to get all posts, however I’ve searched and performed with concepts however nothing received near doing what I want. Here is what I’ve at present received:

perform exclude_category( $question ) {
    $this_cat = get_query_var('category_name');
    if ( $query->is_home() && $query->is_main_query() ) {
        $query->set( 'cat', '-8,-54' );
        $query->set( 'posts_per_page', 7 ); // Homepage 7 posts.
    }
    if (
        $this_cat == 'Locations' ||
        $this_cat == 'Africa & Australasia' ||
        $this_cat == 'Asia' ||
        $this_cat == 'Central Europe' ||
        $this_cat == 'Japanese Europe' ||
        $this_cat == 'Israel/Palestine & the Center East' ||
        $this_cat == 'North America' ||
        $this_cat == 'Scandinavia' ||
        $this_cat == 'South America' ||
        $this_cat == 'Western Europe'
    ){
        $query->set('posts_per_page',10000); // Get all of the locations directly for map.
    }
  }
add_action( 'pre_get_posts', 'exclude_category' );

I’ve thought of throwing out the WP_Query and working it once more to get all, and if I do not get a greater answer, that may be the place I find yourself.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments