WordPress.org

Forums

[resolved] Categories in Front Page.... confused (8 posts)

  1. yorgict
    Member
    Posted 6 years ago #

    Hi all,

    I looked for an answer to this but my front page has this:

    <h7 align="center">LATEST NEWS</h7>
    
                              <?php if (have_posts()) :?>
    
                <?php while (have_posts()) : the_post(); ?>
    
    				<div class="post-wrapper">

    Based on the above (and I have tried to no avail) how do I limit the categories in the front page. In other words if I wanted any category "Latest News" on the front and the other info on the inside. How does this happen? I even tried with another template with this breakdown:

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

    Still confused.

    Please help.

    Thanks
    Yorgi

  2. Xamataca
    Member
    Posted 6 years ago #

    You can restrict the categories displayed in your front page by using in_category() in the loop.
    At the codex:
    http://codex.wordpress.org/Template_Tags/in_category

  3. yorgict
    Member
    Posted 6 years ago #

    Sorry but I tried this:
    <h7 align="center">LATEST NEWS</h7>

    <?php if (in_category('3')) :?>

    <?php while (in_category('3')) : the_post(); ?>

    Did I miss something after looking at the page shown.

    Yorgi

  4. Xamataca
    Member
    Posted 6 years ago #

    <?php if (have_posts()) : php while (have_posts()) : the_post(); ?>
      <?php if (in_category('3')) { ?>
        <!-- stuff here -->
      <?php } ?>

    From http://codex.wordpress.org/Template_Tags/in_category:

    Normally, this tag must be used inside The Loop because it depends on a WordPress PHP variable ($post) that is assigned a value only when The Loop runs.[..]

  5. yorgict
    Member
    Posted 6 years ago #

    Got it Thanks it worked.

    G

  6. ChecMark
    Member
    Posted 6 years ago #

    I know I am not supposed to say I am new to WordPress, but I am - brand new. We've added a blog to our site (www.helloboquete.com) using WordPress, but we cannot find out how to display our categories in the left sidebar. We have researched it now for hours and can't find any info at all. Everything we try fails. Truly appreciate someone "in the know" steering us in the right direction.

    We are also worried, now that we FINALLY got our flash menu working on the page, what will happen if we upgrade the version? We will lose everything we worked so hard to get?

    Thanks.

  7. Rohaq
    Member
    Posted 6 years ago #

    I've tried using in_category(x), however it doesn't seem to work; I essentially want two pages, one that lists entries in a 'Blog' category, and another in 'Articles'.

    Looking at the database, it looks like all of the entries seem to have post_category set to 0. I'm pretty sure that this shouldn't be the case.

    Can anybody suggest any ideas?

  8. Rohaq
    Member
    Posted 6 years ago #

    Solved: I used Advanced Category Excluder to remove the other posts from the front page, and PostLists to create pages with lists of other posts on them, works a treat.

Topic Closed

This topic has been closed to new replies.

About this Topic