• I am new to wordpress and I am trying to insert some php in my head template. What I hope to do is when the home page is live place a custom meta description in the page. If the home page is not live I want no meta description becasue the xfish_meta plug I use will control these pages. This is what I have currently:

    <?php if ( is_home() ) {?>
    <meta name=”description” content=”<?php if ( is_home() ) {
    bloginfo(‘name’); echo ” – “; bloginfo(‘description’);
    }}
    ?>” />

    This is working fine on the home page, but when I go to an individual post it leaves the “/> which I do not want. Can anyone help me fix this?

    Here is my test page:
    Home Page: https://degmsb0.tollfreepage.com

    Individual post with problem: https://degmsb0.tollfreepage.com/?p=20

    Thank you.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Change it to:

    <?php if ( is_home() ) {?>
    <meta name="description" content="<?php if ( is_home() ) {
    bloginfo('name'); echo " - "; bloginfo('description');
    }
    echo "/>";
    }
    ?>"

    Thread Starter degmsb

    (@degmsb)

    Thank you for the quick response. This almost works, but when the page is not my home page it places an extra quote mark in the page under the title. See here: https://degmsb0.tollfreepage.com/?p=20

    Secondly the description appears like this on the home page:

    <meta name=”description” content=”Motorcycle Helmets – This is a test blog/>”

    Instead I need it like the below with the quote inside the />

    <meta name=”description” content=”Motorcycle Helmets – This is a test blog a€? />

    I tried to modify but could not get it to work.

    Do you have any other suggestions?

    Thank you again.

    Oh crap, stuffed up my copy & paste, try this instead sorry about that:

    <?php if ( is_home() ) {?>
    <meta name="description" content="<?php if ( is_home() ) {
    bloginfo('name'); echo " - "; bloginfo('description');
    }
    echo "\"/>";
    }
    ?>

    Thread Starter degmsb

    (@degmsb)

    Worked Perfect, Thank you so much!!!

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