• WPChina

    (@wordpresschina)


    Hi,
    I just changed over from MT to WordPress and it is fantastic–so much easier and it is a big big big relief!

    I am tweaking my blog now and can’t figure out how to do something that I had on my MT blog:

    My blog has about 6 categories of information. However on the front page (homepage) I only want to show the latest post from my category called “Daily Thought”. I don’t want to show any other categories’ posts–only the latest in “Daily Thought”.

    In the Options, I have already chosen to only display one blog post per page, but I can’t figiure out how to only show a specific category on the homepage

    What file do I need to change and what code should I add? I assume I need ot edit Main Index Template in the templates, right?

    Many thanks for your help. I am a new WP user and I hope the suport and forums here are much better than MT. 😉

    Thank you!

Viewing 9 replies - 1 through 9 (of 9 total)
  • in the index.php in your template file (under wp-content/themes) under this line:


    <?php while (have_posts()) : the_post(); ?>

    add this line, replacing 10 with the category number of your daily thought category:


    <?php if ( (in_category('10'))) { ?>

    Then above this line:


    <?php endwhile; ?>

    Add this line:


    <?php } ?>

    This might not be the cleanest way to do it, but it should get the job done. It’ll cause the wordpress loop to only display posts in that category and if you’ve told it to only display one post then you should be all set.

    Use the following plugin. (The instruction in on the file)
    http://dev.wp-plugins.org/file/front-page-cats/trunk/front_page_cats.php?rev=57&format=raw

    oh yeah, plugin…. that would be easier. when i first did this (though backwards, i wanted it so that one of my categories would not show up on my home page) i don’t think that there was a plugin for that yet.

    🙂

    Thread Starter WPChina

    (@wordpresschina)

    Great, thank you–so fast!

    I just tested this and it seems odd how it works. I only want to show 1 article (the latest) from category 3 on the homepage, but it won’t show the latest post, from a few days ago, there. However when I change it to category 5, which has a post from yesterday, it works fine. I tried with my other categories, and they also do not work–the only one that works is the category 5 which has a post from yesterday.

    I thought maybe it was a problem with my WP2.0 settings in Options/Reading, but the Blog Pages is set to show at most 1 post.

    Any idea what could be going wrong? I am testing this on a local machine not connected to the Internet, so i can’t give you a URL to check unfortunately.

    Thank you for your help.

    Thread Starter WPChina

    (@wordpresschina)

    Ah, wait! the plugin was posted as I was typing 🙂

    Ok, I will check out that plugin for 2.0!!

    many thanks!

    Thread Starter WPChina

    (@wordpresschina)

    Ok, I installed the plugin and made it point to my one category at “3”, but now the front page is not showing anything. After I Activate the plugin, do I need to do anything else? Should it just automatically run or should I place some code in a file somewhere?

    thank you!

    Thread Starter WPChina

    (@wordpresschina)

    Ah, got it working now. Dumb mistake on my end….

    Thanks for the tips. Exactly what I needed!

    This is just what I was looking for.

    I’m using wp1.5+ and I encountered the problem that WordPressChina met. I’m just wondering how to solve it i.e. viewing posts that were not only posted recently.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Showing only 1 post from a specific topic on homepage’ is closed to new replies.