Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
Photo

wordpress category exclusion from blog page


  • Please log in to reply

#1
Dreylivude

Dreylivude

    Member

  • Member
  • PipPipPip
  • 109 posts
Hello everyone. I've been trying to figure out how to get a certain category in my blog to not show up in the main blog page. I've been having some trouble with this. I've tried two bits of code:

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

<?php static $count = 0;
if ($count == "n") { break; }
else { ?>

<?php if ( in_category('x') && !is_single() ) continue; ?>
<?php if ( in_category('y') && !is_single() ) continue; ?>
<?php if ( in_category('z') && !is_single() ) continue; ?>

<div class="post">
<?php the_content(); ?>
</div>

<?php $count++; } ?>
<?php endwhile; ?>
<?php endif; ?>[/codebox]

This was a whole new loop that I decided to use to clean things up, but the category exclusion code in there somehow only makes my blog show one post, the latest one.

Then I tried:

[codebox]if (is_home()) if (in_category(’14′)) continue;[/codebox]

But that just broke my blog. It said not found. I believe that doesn't work because my blog page isn't the home page in my wordpress site. That is the same reason why I think the plugins for this sort of thing didn't work. I tried two.

Any suggestions would be great. Thank you.

Edited by Dreylivude, 01 March 2009 - 07:17 PM.

  • 0

Advertisements


#2
Metallica

Metallica

    Spyware Veteran

  • GeekU Moderator
  • 31,676 posts
Hi Dreylivude,

Can you post a link to your blog?
Some of the code depends on the theme you are using.
  • 0

#3
Dreylivude

Dreylivude

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 109 posts
It's actually my own custom theme. I don't really know much about php so I just kinda hobbled it together, probably not in the best way. It works for the most part, but I'm very lost when I want to change something.

My site is m-cub3d.com
  • 0

#4
Metallica

Metallica

    Spyware Veteran

  • GeekU Moderator
  • 31,676 posts
The site sure looks good. :)

As far as I can tell your php code contains some syntax errors, but none show up at your site.

Can you let us know what you want the piece of code to do exactly?
  • 0

#5
Dreylivude

Dreylivude

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 109 posts
Well I mentioned that in my first post. See my site is a portfolio site for my work to show employers. I'm in school right now and have been using it for group work to show my teachers, so because of that there are posts in the blog section that are not by me. I want to be able to exclude a certain category from the blog section so perspective employers won't assume I did something that wasn't actually mine. So I just don't want a certain category to show up on the main blog page.
  • 0

#6
Metallica

Metallica

    Spyware Veteran

  • GeekU Moderator
  • 31,676 posts
Yeah, but I don't see any categories listed anywhere, so I can't tell what you want to change.

See if you can get it done with these instructions:
http://faq.wordpress.net/view.php?p=56
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP