Support » Themes and Templates » Custom Post Type and Taxonomy pagination permalink 404 error

Viewing 13 replies - 1 through 13 (of 13 total)
  • Loop code for taxonomy.php

    [Code moderated as per the Forum Rules. Please use the pastebin]

    Please guyz help me my ………… i have created a custom page template and pagination is working fine on page

    http://www.kingdomcms.com/wordpress/mechnair/for-sale/

    but i need pagination on taxonomy.php file

    http://www.kingdomcms.com/wordpress/mechnair/equipments/for-sale/

    I got the same problem and still try to figure it out. Any luck?

    No dude i didnt find any solution but because i have limited categories so i have created pages for each category with same name and assigned that template. Pagination is working fine on custom page template. Here is my query for custom page template but i dont think it is the right way to do this.

    [Code moderated as per the Forum Rules. Please use the pastebin]

    thanks dude, at least there is a temporary solution that works. still trying to figure out the best solution. I found a pagination chaining tutorial by Justin Carroll in wptuts and the results for me is still the same but may be you can try that method and tell me whether it works or not

    Thanks for the link man but result is still same for me too πŸ™

    Hey Dude, I found the way to get the pagination fix!!

    first thing you need to know is do not add custom query_posts at your taxonomy.php it will ruin the pagination so get rid of it.

    second remove the exclude_from_search -> true while registering the post type

    third don’t register custom taxonomy with priority lower than priority for registering associated post type.

    example

    add_action('init', 'custom_post_type_register', 0);
    add_action('init', 'custom_tax_register', 10);

    if you want to add custom query to your taxonomy instead of using query_posts, just create another functions in functions.php then using pre_get_posts filter

    function search_filter($query) {
    	if ( !is_admin() ) {
    	    if ($query->is_search) {
    			$query->set('post_type', array('post', 'page'));
    	    }
        }
        return $query;
    }
    add_filter('pre_get_posts', 'search_filter');

    This is use to filter the search to only search for post and page if you want to add the custom post type just append it in to the array.

    if you want to make custom post per page use this functions

    $option_posts_per_page = get_option( 'posts_per_page' );
    $option_taxposts_per_page = (int)(get_option('my_custom_option');
    if($option_taxposts_per_page['st_search_results_show'] == ''){ $option_taxposts_per_page = $options_posts_per_page;}
    
    add_action( 'init', 'my_modify_posts_per_page', 0);
    function my_modify_posts_per_page() {
    	add_filter( 'option_posts_per_page', 'my_option_posts_per_page' );
    }
    function my_option_posts_per_page( $value ) {
    	global $option_posts_per_page;
    	global $option_taxposts_per_page; // your custom posts per page options
    	if ( is_tax( 'mytaxonomy')) {
    		return $option_taxposts_per_page;
    	}
    	else {
    		return $option_posts_per_page;
    	}
    }

    the if($option_tax_posts_per_page[‘blablabla’] is my custom framework option. use your own (forget to change it) πŸ˜€

    the line 3 for the last code block is my own custom framework option. use your own (forget to change it) πŸ˜€

    I don’t know if it has to do with the pagination but in my post_type the ‘has_archive’ is set to true, ‘has_archive’ => true,

    Wow it works man. Thanks
    I have just removed the exclude_from_search -> true while registering the post type …… nothing else and it works for me

    Thanks alot for all your help…really appreciated

    Also i have used search_filter function to filter the search … just like you did

    Nice to hear that you also got it fix. Fun with taxonomy then πŸ˜€

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Custom Post Type and Taxonomy pagination permalink 404 error’ is closed to new replies.