• Hi I am new to PHP and I need a basic help. I have a block statement which defines all titles as <h2>. I don’t want the title on Home page to be <h2>. How do I do that. Here’s the code:

    <h2><?php if (is_page('Home')) { echo "Minty's News"; } else if (is_page('Contact')) { echo "Contact -&nbsp;&nbsp;&nbsp; Tel: +44(0)203 2397692 &nbsp;&nbsp;&nbsp;Mob: +44(0)7989 194003&nbsp;&nbsp;&nbsp; email: [email protected]"; } else if (is_page('Guest Book')) { echo "How was it for you?"; } else { echo "";the_title(''); } ?></h2>

    Thanks

    And how do I define a class inside of the code.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You need to deal with the <h2> tags inside your php code.

    So something along the lines of
    if (!is_home()) {echo '<h2>';} else {echo '<h1>';}

    … do stuff …

    if (!is_home()) {echo '</h2>';} else {echo '</h1>';}

    Or if you don’t want the home page to be in header tags at all, just leave out the PHP from else onwards.

    Thread Starter sasa2209

    (@sasa2209)

    I don’t seem to get it. I have done some changes but still title on a Home page appears as a <h2>:

    <div id="page" <?php if (is_page('Home')) { echo "style=\"width:295px; float: right; background-color: #012530;\""; } else if (is_page('Offers')) { echo "style=\"width:677px;\""; } else if (is_page('Guest Book')) { echo "style=\"width:980px;\""; } else { echo""; } ?>><h4><?php if (is_page('Home')) { echo "Minty's News"; } ?></h4><h2><?php if (is_page('Contact')) { echo "Contact -&nbsp;&nbsp;&nbsp; Tel: +44(0)203 2397692 &nbsp;&nbsp;&nbsp;Mob: +44(0)7989 194003&nbsp;&nbsp;&nbsp; email: [email protected]"; } else if (is_page('Guest Book')) { echo "How was it for you?"; } ?></h2>

    How do I solve this? Or could someone do it for me please?

    Thanks

    You still have your <h2> tag outside of the php if statements. PHP will only dynamically control stuff inside the if statements.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘class inside of php’ is closed to new replies.