Wordpress Themes - WP Forum at BFA
There will be no more development for Atahualpa (or any other theme), and no support. Also no new registrations. I turned off the donation system. I may turn the forum to read only if it gets abused for spam. Unfortunately I have no time for the forum or the themes. Thanks a lot to the people who helped in all these years, especially Larry and of course: Paul. Take care and stay healthy -- Flynn, Atahualpa developer, Sep 2021

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


 
Prev Previous Post   Next Post Next
  #1  
Old Apr 1, 2011, 03:09 PM
sradhey
 
9 posts · Aug 2010
PHP code to display posts from certain categories on homepage

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
 

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 04:20 PM.


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