For RSS feeds of multiple categories, is there a way to ensure that a certain number of posts from a particular category always get shown?
-
If I want to get feeds from category ID 1, 2, and 3, this works. http://localhost/wordpress/feed/?cat=1%2C2%2C3 That is great. Let's say I have 100 posts from ID 1 and 50 posts from ID 2 and 10 posts from ID 3. The category 1 gets updated almost every day. The category 2 is not that often but gets updated regularly. The category 3 updates occasionally but has very important information. So I'd like to make the feed contain a certain number of posts from category 3 which will be shown always like a sticky thread in a forum. Also some posts of category 2 should be fed as well. I mean I do not want the feed to be occupied with the posts of the category 1. For example, if there are 20 articles in the RSS feed and I want to include at least 4 from the category 3, and 6 articles from the category 2, and 10 from the category 1. Is it possible to do?
-
Answer:
You would have to create a custom feed. That is possible using add_feed function [https://codex.wordpress.org/Rewrite_API/add_feed]. A simple example for usage of this function: [http://resources.mdbitz.com/2010/08/creating-a-custom-feed-in-wordpress/]. The " $posts = query_posts('showposts=5');" line is the key - here you can form an array of posts and sort it in any way you like - just the way you would do if you were building a custom loop for your theme. P.S. You will need to flush rewrite rules once, after adding this to your theme/plugin. You can do that either by visiting Settings>Permalink page in admin area, or by calling flush_rewrite_rules() function. You only need to do this once, not on every load.
Arūnas Liuiza at Quora Visit the source
Related Q & A:
- Where can I see a video being used by a certain camera?Best solution by Quora
- Is it bad if I play a mini DV tape on a camcorder that was recorded on a different camcorder?Best solution by friendsofhdvideo.com
- Will a phone number show up on a landline bill?Best solution by Yahoo! Answers
- Do I need a Headphone amp to use a pair of Audio Technica ATH A-700 headphones with an iPod?Best solution by Yahoo! Answers
- Is there a way to find out a password?
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.