ThemeShaper Forums » Thematic

[closed]

Next post and previous post in category archive

(4 posts)
  • Started 8 years ago by astima
  • Latest reply from ocube
  • This topic is not resolved
  1. astima
    Member

    this is more of a general question (I think). Once I get the answer I will be able to ask more specific question.

    My question is:

    How come when you are on a category page and you click either the next post or the previous posts it does not take you to the next or previous posts in that category. Instead it takes you to the next or previous post in the order they are posted.

    Is it possible when you are on a category page to be able to click through only the posts in that category? And if it is possible where do I learn how to do it?

    Posted 8 years ago #
  2. AnotherAndrew
    Member

    Astima,

    I struggled with the same question and someone helped me with the code below.

    Use the code below but change "10" to be whatever the id of the category you would like to keep the navigation in.

    // arguement for news section, exclude other categories from navigation, 10 being news category
    function custom_previous_post_link_args($args){
    	if(in_category(10)){
    		$args['in_same_cat'] = TRUE;
    	}
    	else{
    		$args['excluded_categories'] = 10;
    	}
    	return $args;
    }
    add_filter('thematic_previous_post_link_args', 'custom_previous_post_link_args');
    
    function custom_next_post_link_args($args){
    	if(in_category(10)){
    		$args['in_same_cat'] = TRUE;
    	}
    	else{
    		$args['excluded_categories'] = 10;
    	}
    	return $args;
    }
    add_filter('thematic_next_post_link_args', 'custom_next_post_link_args');
    Posted 8 years ago #
  3. For any category or tag or taxonomy; the same fellow that makes the WP_PageNavi plugin also makes the Smarter Navigation plugin. With that installed and activated you can paste the following into your Child Theme functions.php file:

    function childtheme_override_next_post_link()
    {
    	if ( function_exists( 'next_post_smart' ) )
    		next_post_smart();
    }
    add_action( 'thematic_next_post_link', 'childtheme_override_next_post_link' );
    
    function childtheme_override_previous_post_link()
    {
    	if ( function_exists( 'previous_post_smart' ) )
    		previous_post_smart();
    }
    add_action( 'thematic_previous_post_link', 'childtheme_override_previous_post_link' );

    -Jeff

    Posted 8 years ago #
  4. @diverge
    Thanks for that... saved me what might have turned out to be a long night, now I can go watch a movie instead.

    Posted 7 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.