Skip to content
WJunction - Webmaster Forum

[Tutorial] - How to Keep your WP Blog Homepage Clean!

Status
Not open for further replies.
[Tutorial] - How to Keep your WP Blog Homepage Clean!
Im using this method in my blog WRZBlog.net to post XXX Uploads and still have a clean homepage. (ie:without XXX Posts)

These two lines of code basically use the WordPress query_posts() function to exclude posts in a certain category. The first line of code fixes the pagination issue of all posts being displayed on all pages. Again, let’s say that we want to exclude all posts from the category with an ID of 8 from our index page.
Simply place the following code in your index.php file before this line

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

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

Issues with this method:
This method will remove posts that are ONLY in the excluded category. If a post is in the excluded category as well as another category they will still show up on the home page.
 

2 comments

Status
Not open for further replies.

About the author

Fred
Active Member · Joined
1,359
Messages
7
Reactions
38
Points

Advertise on WJunction

Reach 1000's of webmasters, hosts & affiliates. Banner & sponsored-thread slots available.

Contact us
Back
Top Bottom