Wordpress Themes - WP Forum at BFA

Wordpress Themes - WP Forum at BFA (http://forum.bytesforall.com/index.php)
-   Center area post/pages (http://forum.bytesforall.com/forumdisplay.php?f=32)
-   -   PHP code to display posts from certain categories on homepage (http://forum.bytesforall.com/showthread.php?t=13609)

sradhey Apr 1, 2011 03:09 PM

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 ?

sradhey Apr 1, 2011 03:48 PM

Problem resolved thanks


All times are GMT -6. The time now is 03:50 AM.

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