Wordpress Themes - WP Forum at BFA
Click here to register or to donate.
Auto self-registration is not available here - far too many spammers. This forum has many, many backlinks and because of that there is an intense desire among spammers to drop their links here.

Wordpress Themes - WP Forum at BFA » WordPress Themes » Atahualpa 3 Wordpress theme » Center area post/pages »

PHP code to display posts from certain categories on homepage

Old Apr 1, 2011, 04:09 PM
9 posts · Aug 2010
I am using Content ABOVE the LOOP area to show some posts from certain categories only on the homepage.

I am using the following code to show 5 posts from category 3:

<?php query_posts('cat=3&showposts=5'); ?>
<?php while (have_posts()) : the_post(); ?>
<li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>
<?php endwhile;?>

It works perfectly but then the same output is shown IN THE LOOP as well.
I want IN THE LOOP to display all the rest of the categories (everything expect category with id 3).
This happens in spite of using the foll code at the end of Content ABOVE the LOOP

<?php if (is_home() || is_front_page())
query_posts($query_string . "&cat=-3");

I don't want to use plugins like Advanced Recent Posts though that solves my problem.
How do I do this in PHP coding - I am not good at it ?

Last edited by sradhey; Apr 1, 2011 at 04:21 PM. Reason: updated code
Old Apr 1, 2011, 04:48 PM
9 posts · Aug 2010
Problem resolved thanks


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
Thread Thread Starter Forum Replies Last Post
Display posts alphabetically for one category, chronologically for other categories spencer Atahualpa 3 Wordpress theme 4 Jul 16, 2014 10:01 AM
PHP code issue while showing posts from a certain category sradhey Center area post/pages 2 Apr 1, 2011 04:35 PM
How do I display posts excerpts from specific categories on the homepage? aeerol Center area post/pages 0 Jun 12, 2010 05:32 PM
Display the posts within a catagory as my Homepage bloggersmarket Page & Category Menu Bars 1 Apr 15, 2010 07:46 AM
[SOLVED] Display full posts in categories kam Center area post/pages 2 Jan 26, 2010 02:35 PM

All times are GMT -6. The time now is 01:52 PM.

Powered by vBulletin® Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.