March 6, 2014 at 4:05 am #5033
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.March 7, 2014 at 9:31 am #5066RaghavendraModerator
Does this help?
[show_post_snippets number_of_columns=3 post_count=6 image_size='large' terms="news,whatever" taxonamy="category" post_type="post"]March 7, 2014 at 9:37 am #5068
Where do I put this?
Which file should I modify?March 7, 2014 at 9:56 am #5073RaghavendraModerator
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.March 17, 2014 at 6:42 am #5216
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…?
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?March 18, 2014 at 5:02 am #5258ErnestoMember
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-idMarch 19, 2014 at 1:00 am #5278
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.March 19, 2014 at 1:37 am #5282ErnestoMember
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.March 19, 2014 at 2:58 am #5291
Thank you it all works like a charm!
- The topic ‘Can display all post except for particular categories posts at blog page?’ is closed to new replies.