tags:

views:

9

answers:

1

Right now the header has a bit of code in it that queries the section name and then uses that section name as the h1 title in the page. It works fine. However, I want to selectively break that operation in certain categories and give myself the ability to manually enter the h1 title for a given section. Here's what I'm struggling with: how can I maintain the automatic query and title selection in most instances, but selectively break it in a given category (the 'blog' category, for starters)?

Thanks for taking a look, I appreciate your help!

Here's the code that drives the existing function (it's the get_the_section_name part):

    <?php if(!is_home()){?>
    <div class="section <?php echo get_the_section_name();?>">
        <?php 
        $sectitle = get_the_section_name();
        $sectitle = str_ireplace("-"," ",$sectitle);
        echo '<h1>' . $sectitle . '</h1>';?>

        <p class="breadcrumbs">
            <?php
            if(function_exists('bcn_display'))
            {
                bcn_display();
            }
            ?>
        </p>
    </div>
    <div class="columns">       
    <?php } ?>

Here's a page that shows what it looks like displayed (see the title in the blue graphic underneath the main nav near the top of the page): http://69.20.59.228/category/blog/

A: 

Insert following code before line

echo '<h1>' . $sectitle . '</h1>';?>

Simply add more elements to $special_categories array

$special_categories = array(
    "blog" => "Special blog title",
    "other category" => "Another special category title",
);

if (array_key_exists($sectitle, $special_categories)) {
    $sectitle = $special_categories[$sectitle];
}
Tomasz Tybulewicz
it's not working... is there a missing parenthesis on the end of the "if (array_key_exists" statement?
poindexter
ok, I just added another parenthesis and it's working now... thanks!
poindexter
Code fixed, thanks for notice ;)
Tomasz Tybulewicz