• I know this may sound like a crazy request, but I just want to alter the output in the title tag so there is no space between the blog name and the title of the post. I have tried:

    <title><?php bloginfo('name'); ?><?php wp_title(''); ?></title>

    and although this removes the default &rquo; it leaves a space behind.

    Is there any way of getting rid of this space? Thanks.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Give this a shot. Depending on your choice of meta title code, it will also remove the blank white space from the beginning of the page code title. So, instead of <title> Here’s my page title</title>, you’ll see <title>Here’s my page title</title>. See code below. Hope it helps.

    trim(wp_title(”, false))

    Maybe in your case, you could try this. I haven’t verified/tested, but should work ok. Either way, the important piece of code is above.

    <title><?php bloginfo(‘name’); ?><?php trim(wp_title(”, false)); ?></title>

    anotherword’s solution won’t work, because wp_title prints its output before trim can trim it. Besides, the space is within the string.

    To trim out the separator and surrounding spaces, put the following in your theme’s functions.php template file:

    add_filter('wp_title', create_function('$a, $b','return str_replace(" $b ","",$a);'), 10, 2);

    Stick the following in your functions.php file, located within your theme folder.

    // Removes the white spaces from wp_title
    function af_titledespacer($title) {
    	return trim($title);
    }
    
    add_filter('wp_title', 'af_titledespacer');

    Hope that helps. ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘adjust wp_title to remove space’ is closed to new replies.