• Hiya, I’m using the Drunkey Love theme and I would like to insert a html file above the menu. I’m having trouble with the php ifs and else’s.

    What I want is for if the page is home, then a certain div id and a certain file shown, and then if its not then a different div id and a different file inserted.

    Any ideas?

    Thanks.

Viewing 7 replies - 1 through 7 (of 7 total)
  • I’m fairly sure this will work.
    It covers 3 conditions: home / page / everywhere else.

    <?php
    if (is_home()) {
    echo '
    Put_stuff_here
    ';}
    elseif (is_page()) {
    echo '
    Put_different_stuff here
    ';}
    else {
    echo '
    And_the_rest_goes_here
    '; }
    ?>

    Thread Starter jmd4eva

    (@jmd4eva)

    Thanks

    To include a html file, would the normal php include work?

    Yep, just do NOT include the whole file (meaning: html, head, body etc.) just cut out the portion you need into a file. By including a whole file you will end up with 2 heads, 2 bodies etc.

    Thread Starter jmd4eva

    (@jmd4eva)

    Thanks for your help!

    I would also like to hide the date and time of specific posts, is that possible?

    Thanks again.

    Maybe if those posts have something in common and if the “commonality” can be defined for WP. Otherwise, just like depending on the weather or your mood – no 🙂

    Thread Starter jmd4eva

    (@jmd4eva)

    Hiya,

    I’ve put the php if and else thing in, and its calling the right page in the code, but its just not working!!

    the site is http://www.jdoman.com/hunch – any ideas?

    Try changing your PHP code tag to:

    <?php include("your-url"); ?>

    Using <? ... ?> does not work on all servers, so it’s safest to use the standard <?php ... ?> tag format.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘PHP if and ELSE’ is closed to new replies.