Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

In my Wordpress site I've created, I'm having issues hiding or not displaying one of the category titles I set up. I'll try to explain better.


Wordpress Admin Side

I have a post that is in two categories, a "Work" & "Front_Page"


Main Page / index.php

On my main index page, I have 3 features below the header image. One of those features is a "Featured Project". This is how I'm starting the loop...


Single Project Page

Now on this page, the visual layout is

Category Name

Which is called <h2 class="single_category"><?=$cat[0]->name;?></h2>

Project Title
Large Header Image
Project Desription

THE PROBLEM!!!

For whichever post I put in "Front_Page", it displays that in the Category Name. I want it to default to the main category.

Is there a way to basically say "if post is in "front_page" category, don't display "front_page" category as name?

share|improve this question
    
Please upload your whole theme's sourcecode so it can be better said what your issue is. –  hakre Jan 23 '11 at 1:14
    
Please don't use shorthand php tags for code samples, not everyone has them enabled. –  t31os Jan 23 '11 at 10:45

1 Answer 1

up vote 0 down vote accepted

Here is a bad way that works.

<h2 class="single_category"><?
if ($cat[0]->name != "Front_Page") {
    echo $cat[0]->name;
} else {
echo $cat[1]->name;
}
?></h2>

Here is a bad way that works and takes up less space.

<?php echo ($cat[0]->name != "Front_Page") ? $cat[0]->name : $cat[1]->name; ?>
share|improve this answer
    
Thanks cbrandolino, I used the first one, worked like a charm. –  Matt Jan 23 '11 at 1:55
    
Please don't use shorthand php tags for code samples, not everyone has them enabled. –  t31os Jan 23 '11 at 10:45

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.