WordPress.org

Ready to get started?Download WordPress

Forums

wp_title (6 posts)

  1. magicmark
    Member
    Posted 2 years ago #

    Hi

    I am trying to set the decription meta tag for each page by adding in the wp_title as follows:

    <meta name="description" content="Continually updated to collate the latest <?php wp_title('',true,'right'); ?>news from across across the accountancy profession.">

    However, if the wp_title is "Contact" or "Link to Us" I would like it to be blank ie so that the the content reads "Continually updated to collate the latest news from across across the accountancy profession."

    Also, how do I get rid of the extra space which is inserted after wp_title as part of the seg?

    Many thanks
    Mark

    [Please post code snippets between backticks or use the code button.]

  2. esmi
    Forum Moderator
    Posted 2 years ago #

    Try:

    <?php $insert = ' ';
    if( !is_page( 'Contact' ) && !is_page( 'Link to Us' ) ) $insert .= wp_title("",false);?>
    <meta name="description" content="Continually updated to collate the latest<?php echo $insert;?>news from across across the accountancy profession.">
  3. magicmark
    Member
    Posted 2 years ago #

    Thank you - that works for Contact and Link to Us.

    However, for a page where for example the wp_title is 'Tax' the following is produced:

    <meta name="description" content="Continually updated to collate the latest Taxnews from across across the accountancy profession.">

    There are 3 spaces before wp_title and none afterwards?

    Thanks
    Mark

  4. esmi
    Forum Moderator
    Posted 2 years ago #

    Try:

    <?php $insert = ' ';
    if( !is_page( 'Contact' ) && !is_page( 'Link to Us' ) ) $insert .= wp_title("",false) . ' ';?>
    <meta name="description" content="Continually updated to collate the latest<?php echo $insert;?>news from across across the accountancy profession.">
  5. magicmark
    Member
    Posted 2 years ago #

    Thank you - that adds a space after the wp_title but there are still 3 spaces appearing before the title.

    Thanks
    Mark

  6. magicmark
    Member
    Posted 2 years ago #

    I have reduced it to 2 spaces by changing

    <?php $insert = ' ';

    to

    <?php $insert = '';

    but this still leaves 2 spaces instead of one before the wp_title.

    Thanks
    Mark

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags