donalyza.com

Avatar

Hello! I'm Donalyza Agaton, a Blogger who loves Web Design, a rock and r&b Audiophile, a psp Gamer, a hobbyist Photographer, an amateur Videomaker, a gadget geek Girl, and a proud Filipino.

donalyza: Yehey its now drizzling in Quezon City-finally!, on my way to the airport to drop-off my dad. He's back to work. 3 hrs ago

How To: Exclude Categories to be Posted on FrontPage

Posted in: WordPress

On this post I will show you how to hide a particular post on your blog’s front page without the need to install a plugin. I have nothing against WordPress plugins it’s just that I’m the type of WordPress blogger who is as much as possible doesn’t want to install a plugin especially if there’s a code that I can use and do it manually by editing my theme’s template. On today’s post I will show you on how to exclude categories to be posted on your frontpage of your WordPress blog. This WordPress tweak has been tested in WordPress 2.3. This definitely works especially if your frontpage has page navigation.

* This varies depending on your theme, this is commonly used in a normal wordpress blog layout.

  1. Go to admin dashoard > manage > categories. Look for the category you want to exclude and identify the category ID. e.g. we want to hide category ID: 8.
  2. Still in the admin dashboard > go to Presentation > Theme Editor > open *index.php
  3. Inside the *index.php file, look for the line that says “<?php if (have_posts()) : ?> ”
    then paste this code after that line:
    ! don’t forget to change the id to your chosen category id

    <?php $page = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts("cat=-8&paged=$page"); ?>

    and before this code. “ <?php while (have_posts()) : the_post(); ?>

  4. Then Update your *index.php file.

Don't miss any post. Subscribe to RSS or by email now.
Tags:

Comments

RSS feed | Trackback URI

14 Comments »

Saturday, March 15, 2008 at 7:19 am

This is a good tips that I will try soon.
Thanks mate.

 
Sunday, August 3, 2008 at 11:57 pm

thanks ,works perfectly.

Monday, August 4, 2008 at 7:15 am

No problem. Glad I was able to help you out.

Saturday, January 31, 2009 at 11:44 pm

Can’t see all the code maybe in this browser?

The code to add is this?

! don’t forget to change the id to your chosen category id
<?php $page = (get_query_var(’paged’)) ? get_query_var(’paged’) :

where is the category type placed?
Thanks,
Todd

(Comments wont nest below this level)
Wednesday, August 19, 2009 at 12:11 pm

You are right Todd… It is also not working for me too. I am going to try in other browser.

 
Friday, August 21, 2009 at 3:51 am

jaaahhh… where i have to put the categoryid?? paged???

 
Friday, August 21, 2009 at 4:04 am

try this guys:

it works!… place this code as same as dona’s mentioned above

 
Friday, August 21, 2009 at 4:08 am

sorry, this the code, (i forgot to replace it as html code)

<?php
if (is_home()) {
query_posts("cat=-3");
}
?>

 
 
 
 
Sunday, September 7, 2008 at 9:03 pm

Not working for me… I am using version 2.6.1. Where to change the category id?

 
Sunday, November 9, 2008 at 4:15 pm

Thank you, it works on my 2.6.3 :)

 
Tuesday, August 25, 2009 at 12:41 pm

Here is another way to do it. You can use this code snippet in the index.php file instead:

 
Tuesday, August 25, 2009 at 12:42 pm

 
Your Ad Here

Trackback responses to this post

Leave a Comment, Win a Friend!

Name (required)
E-mail (required - never shown publicly)
URI
Your Comment (smaller size | larger size)
You may use <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> in your comment.
blog stats