Wordpress Themes - WP Forum at BFA
Click Here To DONATE! Support the theme development, get more attention and additional benefits based on your donation level. Your forum name will be highlighted.

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


Build custom WP THEMES, without
coding.
Click here for THEMEFRAME

From the author of Atahualpa, the #1 most
downloaded (700,000+) theme @ wordpress.org
  #1  
Old Apr 1, 2011, 03:09 PM
sradhey
 
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'); ?>
<ul>
<?php while (have_posts()) : the_post(); ?>
<li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>
<?php endwhile;?>
</ul>

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 03:21 PM. Reason: updated code
  #2  
Old Apr 1, 2011, 03:48 PM
sradhey
 
9 posts · Aug 2010
Problem resolved thanks

Bookmarks

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 09:01 AM
PHP code issue while showing posts from a certain category sradhey Center area post/pages 2 Apr 1, 2011 03:35 PM
How do I display posts excerpts from specific categories on the homepage? aeerol Center area post/pages 0 Jun 12, 2010 04:32 PM
Display the posts within a catagory as my Homepage bloggersmarket Page & Category Menu Bars 1 Apr 15, 2010 06:46 AM
[SOLVED] Display full posts in categories kam Center area post/pages 2 Jan 26, 2010 01:35 PM


All times are GMT -6. The time now is 09:34 PM.


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