• Resolved nickaster

    (@nickaster)


    Howdy – I figured out that the following code will spit out the name of my tag in a template:

    <?php single_tag_title(); ?>

    the problem is this spits the words out in all lower case. Is there some magic php to make it capitalize each word? so that “crazy stuff” spits out as “Crazy Stuff”.

    Thanks!

Viewing 7 replies - 1 through 7 (of 7 total)
  • PHP -> ucwords()

    CSS -> text-transform:capitalize

    Thread Starter nickaster

    (@nickaster)

    umm… cool. so… CSS isn’t going to help because it’s the title field I’m working with. How would I go about sticking that ucwords thing in there? I know basically zero php.

    Is it something like this?

    <?php
    $foo = single_tag_title();
    $foo = ucwords($foo);
    echo $foo;
    ?>

    That’s a seriously illiterate guess…

    That looks about right, actually.

    Thread Starter nickaster

    (@nickaster)

    Hmm…. darn, doesn’t do anything. Oddly, it still returns the name of the tag and doesn’t throw an error, but no caps. Must be something really simple I’m doing wrong no?

    Ok. This works.

    <?php
    $foo = single_tag_title("",false);
    $foo = ucwords($foo);
    echo $foo;
    ?>

    You need the ‘false’ in order to shove the value into a variable.

    However, it only works on tag archive pages.

    Thread Starter nickaster

    (@nickaster)

    Totally awesome. Thanks!

    I know that this says resolved but I’m wondering if it’s still not css. I would open the style.css file in your template directory and search for “lowercase”. It may be that the div for that has a lowercase tag. It just seems like a styling issue to me.

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘php Question – camel caps?’ is closed to new replies.