Showing only one category on homepage

Latest Reply from Tim Cantrell at 2014-08-25 02:59:46
Hello,

I've tried finding an answer on my own but with no success.

I would like only one category to show on the homepage of my website using RetroPress. How do I do this?

I'm guessing I have to modify something in theloop.php, but I'm not very good with PHP so I'm not sure what I should do.

Thanks in advance for any help!

Bertrand
Hi!

Please, try to add the following code:

query_posts('cat=2&showposts='.get_option('posts_per_page'));
after the line:
global $post, $query_string, $SMTheme;

in the file theloop.php. Of course, you have to change the category ID in the expression 'cat=2'.
Hello Dave,

Thank you for your answer and sorry for my very late reply. This works but my menus has links to various the various post categories, and they now all show only the category I indicated in theloop.php.

My idea was to have only posts of the category 4 to show on the front page, and the other ones (category 1 and 2) show separately. If I add :

query_posts('cat=4&showposts='.get_option('posts_per_page'));

then the links to the "1" and "2" category show only posts from "4"...

Any idea how to solve this?


You can also use the "if" construct and the function "is_home()" (see the description here http://codex.wordpress.org/Function_Reference/is_home) to adjust your home page.

Leave a reply

Add codeAdd image