ThemeShaper Forums » Thematic

[closed]

Show posts only labeled as a particular category

(5 posts)
  • Started 4 years ago by eastjane
  • Latest reply from flick
  • This topic is resolved
  1. eastjane
    Member

    I would like to show only posts that are labeled as a particular category and ignore the rest. I think I need to do something with Theme Filters, but I have no clue where to start.

    Please help! Thanks!

    Jane

    Posted 4 years ago #
  2. eastjane
    Member

    I tried the below code and it does NOT work. I am not sure how to edit the loop so it would show posts only related to one category. Please help me solve this issue.

    /*
    *
    * Show only posts marked as 'front' category to show on the homepage
    *
    */
    function childtheme_content($content) {
    	if (is_home() || is_front_page() || is_archive()) {
    		if( is_category('101')){
    				$content= 'full';
    		}
    		else{
                            //Don't show anything
    			$content= 'none';
    		}
    	}
    	return $content;
    }
    add_filter('thematic_content', 'childtheme_content');

    Thanks!

    Posted 4 years ago #
  3. eastjane
    Member

    Just as a clarification, above code shows full posts for post labeled as category 101 and only title + meta information about other posts. However, I would like to not show other posts at all. How do I do that?

    Thanks

    Posted 4 years ago #
  4. eastjane
    Member

    Ok finally figured it out. I added the following in my functions.php file

    /*
    *
    * Show only posts marked as 'front' category to show on the homepage
    *
    */
    function only_front_posts() {
    	if(is_home()|| is_front_page()) {
    		query_posts ($query_string . '&cat=101');
    	}
    }
    add_action('thematic_above_indexloop','only_front_posts');
    Posted 4 years ago #
  5. Thanks for sharing your solution :)

    Posted 4 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.