Can display all post except for particular categories posts at blog page?

Support Forums for LiveMesh Themes & Plugins Forums Extinct Theme Support Can display all post except for particular categories posts at blog page?

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #5033
    palmtree
    Participant

    Hello Code Master.

    At Blog page top where all the posts are displayed. I want not to show particular category post. With my site this Blog page is named “News”. And it’s perfectly fine when all the news related articles are displayed but it’s not good when it comes to display more casual article (there is also a category called “Diary” where people can write their daily life) go inside them mixed up with other serious posts….

    Is there any way to prevent this happening? I know those category IDs that I do not want to display there. (but of course I want to display them when users specifically wants to see that “particular category article”. So want to still keep using category archive view)

    Also the theme has recent post widget. I place it on the right bar of blog page (News page in my website) as well as inside the footer.

    In this also I have to get rid of those casual articles that are not news related…

    It will be absolutely brilliant if you could help me to resolve this!

    Thank you.

    #5066
    Raghavendra
    Moderator

    Does this help?

    [show_post_snippets number_of_columns=3 post_count=6 image_size='large' terms="news,whatever" taxonamy="category" post_type="post"]
    
    #5068
    palmtree
    Participant

    Where do I put this?
    Which file should I modify?

    #5073
    Raghavendra
    Moderator

    You can put it anywhere in the editor for your page. This is a wordpress shortcode for you to use any post/page or portfolio page.

    #5216
    palmtree
    Participant

    Thank you mateorite for your reply:-)

    Your advise only let me display thumnail images or video of each post of particular category… (doesn’t display title text of the post and their links)

    Perhaps my original question wasn’t clear enough to explain what I was after…?
    https://www.livemeshthemes.com/extinct/blog/

    I want this page to output only articles from particular categories.

    Also at the same time, recent post widget doesn’t give users to choose particular category to output so I want to limit its output to display particular category post.

    Does it make sense?

    #5258
    Ernesto
    Member

    Hi,

    Go to the theme folder and open the file “template-blog.php”. In line #23, replace the following code:

    $query = array('posts_per_page' => intval(get_option('posts_per_page')), 'ignore_sticky_posts' => 0, 'paged' => $paged);

    With this new one:

    $query = array('posts_per_page' => intval(get_option('posts_per_page')), 'ignore_sticky_posts' => 0, 'paged' => $paged, cat=-12);

    There, you need to replace the number 12 with the actual ID of the category that you want to exclude. If you don’t know how to find the ID, take a look at this guide: http://www.wprecipes.com/how-to-find-wordpress-category-id

    #5278
    palmtree
    Participant

    Hi Ernesto,

    Thank you for your advise! I tried your code but triggered error. I changed it to code below and seems working but not sure if it’s ok. I want your confirmation if that’s ok. (Actually the category I wanted to exclude was 12 by chance:-))

    $query = array('posts_per_page' => intval(get_option('posts_per_page')), 'ignore_sticky_posts' => 0, 'paged' => $paged, 'cat' => -12);

    Could you help me with “recent posts widget”? Does it include posts from category 12?
    Ideally I would like to add functionality to recent post widget to allow users to choose which category post to output. It would be awesome if you could tell me what code to add to mo-recent-posts-widget.php to achieve this.

    #5282
    Ernesto
    Member

    Hi,
    Go to your Theme Folder, open the file mo-recent-posts-widget.php and search for the following code:

    $loop = new WP_Query(array('posts_per_page' => $post_count, 'ignore_sticky_posts' => 1, 'orderby' => 'date', 'order' => 'DESC'));

    There you’ll need to apply the same modification that you applied in your previous enquire.

    #5291
    palmtree
    Participant

    Ernesto!

    Thank you it all works like a charm!

    Toshi

Viewing 9 posts - 1 through 9 (of 9 total)
  • The topic ‘Can display all post except for particular categories posts at blog page?’ is closed to new replies.