• Resolved yaphi

    (@yaphi)


    I need to turn “About us” into “aboutus” so I went ahead and tried what many have posted here:


    trim(wp_title(""));

    What definitely doesn’t work. Next I tried:


    print trim(strtolower(the_title_attribute('echo=0'))));

    And that still doesn’t work. How can I achieve this?

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

    (@esmi)

    Try <?php str_replace(' ','',strtolower(the_title_attribute('echo=0'))); ?>

    t31os

    (@t31os)

    You can also use the_title('','',false); to prevent the value being returned.

    Just a little easier to write… 🙂

    esmi

    (@esmi)

    But if you use the_title, you’ll need to strip off the tags, won’t you? That’s why I thought using the_title_attribute might be a better approach.

    t31os

    (@t31os)

    Nope, if you set to false it just gives you the title without <a> links.

    😉

    Thread Starter yaphi

    (@yaphi)

    Ahh…I misunderstood trim(). Thanks everyone I got it.

    Thread Starter yaphi

    (@yaphi)

    Oh and for anyone that stumbled upon this, here was the code


    <h2 class="<?php print strtolower(str_replace(' ','', get_the_title($post->post_parent))); ?>"><?php echo get_the_title($post->post_parent); ?></h2>

    This prints an <h2> with a class of the parent’s page title…so if you were on About Us / Contact or something,


    <h2 class="aboutus">About us</h2>

    that way I can replace it with an image.

    This was exactly what I needed! I changed it slightly to pull the current page title, instead of the parent and to only show on pages besides the front page:

    <?php if (!is_front_page()) print strtolower(str_replace(' ','', get_the_title($post))); ?>

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Turning the_title into a css class’ is closed to new replies.