• Hello all

    I am trying to theme the following code in two colors

    I have lloked and seen some examples where using a span and first word second word

    <h1><?php wp_title(''); ?></h1>

    any help would result in lots of hugs and kisses

Viewing 4 replies - 1 through 4 (of 4 total)
  • wp_title() generates the content for the <title> tag in the page’s <head>. It isn’t ordinarily displayed in the page body, and I don’t believe you can style the <title> at all. I’ve never seen it styled, but I guess I’ve never thought about it either. Maybe it is possible, but I don’t think so. The point is that the function isn’t really designed for what you want, so it isn’t geared for styling.

    You need to call it like $my_wp_title = wp_title('',false);, then take that string, manipulate it, and then echo it.

    Thread Starter jimmyg164

    (@jimmyg164)

    Hi thanks for your reply

    I Have restored the following could i theme this to get first word (one color) second word other color

    <h2 class="entry-title">
    			<a href="<?php the_permalink() ?>" rel="bookmark" title="<?php printf(__('Permanent Link to %s', PADD_THEME_SLUG), $title); ?>">
    				<?php
    					$title = get_the_title();
    					if (!empty($title)) {
    						echo $title;
    					} else {
    						_e('(untitled)', PADD_THEME_SLUG);
    					}
    				?>
    			</a>
    		</h2>

    kind regards

    You will need to alter your $title using something like the suggestions here: https://stackoverflow.com/questions/2476789/how-to-get-first-word-of-a-sentence-in-php

    I’d probably do something like:

    echo '<span class="title-first">',substr($title,0,strpos($title,' ')),'</span>',substr($title,strpos($title,' '));

    And it wouldn’t hurt to run striptags(...) on the title first.

    Then you can style the span with CSS.

    Thread Starter jimmyg164

    (@jimmyg164)

    just used the code above and it worked a treat

    cheers s_ha_dum

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘php wp_title('')’ is closed to new replies.