• I’m sorry to start a new thread, but the old one says “resolved” and the links do not work.

    I am trying to have sections on my home page that each shows the last 3 posts from a certain category. I tried the

    query_posts(‘category_name=category name&showposts=3’);

    This works on a category page, but not working on the home page. I get a blank page (just white). If I take out the category_name=category name, then I get the last 3 posts from each category. Once I add the category_name, the page goes blank again.

    Thanks in advance!!

Viewing 7 replies - 1 through 7 (of 7 total)
  • Hi,

    You can do it from index.php file of your theme…and edit the specific category posts from the loop code in that file

    Thanks,

    Shane G.

    Thread Starter sshilo

    (@sshilo)

    Shane,

    As mentioned above, I tried it and couldn’t get the code to work. Could you please post a sample loop code that only uses one category (and works on the home page. As I mentioned, I could get it to work on other pages).

    Thread Starter sshilo

    (@sshilo)

    I just tried it on home.php and could not get it to work there either. I still get a blank page, and if you look at the source, you see that nothing was served…an empty file. Any ideas on what I’m doing wrong?

    Again, I’m simply copying the code from category.php and adding it to the index.php. Works on category.php but not on index.php

    Thread Starter sshilo

    (@sshilo)

    does anyone know? is this just not possible?

    Thank you in advance.

    Try Advanced Category Excluder plugin.

    Maybe something else in your loop on the home page is not quite right. Here’s what I use on my front page:

    <?php query_posts('category_name=Headline'); ?>
    <?php while (have_posts()) : the_post(); ?>
    
    <!-- this is where the title of the Lead Story gets printed -->
    <div class="featurestory">
    <h3><?php the_title(); ?></h3> 
    
    <!-- this is where the excerpt of the Lead Story gets printed -->
    <?php the_content(); ?>
    <?php endwhile; ?>

    It works for me.

    Thread Starter sshilo

    (@sshilo)

    drmanry,

    I didn’t have any other loops on the home page, so I’m not sure what the problem was. I used your code and it worked like a charm!!

    ty, ty, ty, and TY!

    asechrest – I’ll check that out as well.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Display only posts from one category on homepage’ is closed to new replies.