• Resolved OssieW

    (@ossiew)


    Ok, I’ve been puzzling on this for a few days, and i see many other people are asking how to do this. I think I have the answer (well, it’s working on my site).

    So, you want your homepage circles to display posts from one category only?

    Here’s how to do it.

    First step – you need to know the category ID numbers. As they no longer show by default, you’ll need to install a plugin that reveals them. I’m using ‘Reveal IDs’.

    Install and activate the plugin, then go to your Category page and you’ll see the IDs there. Get the number for the category you want to display, then open your index.php (Main Index Template) in Editor.

    before
    <?php /* Start the Loop */ ?>

    add
    <?php query_posts('cat=X'); ?>

    changing X for the ID number of the category you want to display.

    Save it, and check your homepage.

    If you want to exclude one category from your homepage, it’s pretty much the same thing, but instead of

    <?php query_posts('cat=X'); ?>

    you add
    <?php query_posts('cat=-X'); ?>

    Change X for the ID number of the category you don’t want to show.

    It’s worked for me, and it should work for everyone else. I literally figured this out 20 minutes ago, and as so many people have been asking how to do this I thought I’d better share ASAP!

    *edit* proof – go to My site. I’ve excluded the ‘blog’ category from my homepage.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thanks so much! This is amazing. The only thing I cannot figure out is this.

    I now have circles on my homepage. These circles are my categories. But… when I click on them they link to the post, not to the whole category. I really would like to get to a page of that category and see circles of all the posts in that category. (I get to such a page when I click on the menu item on top, strangly.)

    Could you help me with this?

    Thanks a lot!

    Thread Starter OssieW

    (@ossiew)

    Glad I’ve helped a bit!
    I’ve changed my site around so the circles on my homepage link straight to the category pages, rather than showing posts from all but one category on my homepage (as it was before).

    So, to get circles on your home page linking to a category page (with more circles) you’ll need to do this (this assumes you already have ‘Reveal IDs’ installed):

    1. Install and activate a plugin called ‘Page Links To’.

    2. Create pages with the same names as the categories you want to display, and set a featured image for each page. When you edit the pages you’ll see the ‘Page Links To’ options at the bottom. Select ‘a custom URL’, and copy & paste in the URL of the category page (it will be something like ‘https://www.mysite.com/category/whateveritis&#8217; ). Save the page.

    4. Go to the ‘Pages’ page, and get the IDs of the pages you’ve just created.

    5. Edit your index.php (in a child theme – but don’t ask me about child themes, I’m irresponsible and just edited my normal index.php) with the following code:

    before

    <?php /* Start the Loop */ ?>

    change

    <?php query_posts('cat=X'); ?>

    for

    <?php query_posts
    ( array( 'post_type' => 'page', 'post__in' => array( XXX, XXX, XXX ) ) ); ?>

    With ‘XXX’ being the page IDs. You can add as many IDs as you need to, as long as you put a comma between them. If you want some circles to link to actual pages on your site just put their IDs in as well.

    You can use this method to make circles link to outside sites.

    I’ve also figured out some custom CSS for making the homepage circles bigger (when my site is finished I’ll have four circles on my homepage, and the normal size is too small) but that’ll have to be another topic or admin will be in here!

    Hope this helps! ??

    Wow! You’ve made me so happy!

    I’ve puzzled and puzzled for days in a row and I couldn’t figure it out. And it works now!! Thanks so much! ??

    I’m one happy girl on a sunny Sunday.

    Thread Starter OssieW

    (@ossiew)

    No worries, I was banging my head against the desk for days figuring all this out, I thought it’d be mean not to share it ??

    Thread Starter OssieW

    (@ossiew)

    Update – I’ve changed the theme on my site to make it more shop-friendly, so the link above won’t show my modifications in action any more. Sorry!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘One category on homepage – cracked it!!’ is closed to new replies.