• Hi Guys,

    I’m a total PHP and wordpress nube so can you tell me why the code below does not work?

    I basically want to display something on the frontpage(home) and something else on the rest of the pages.

    I was trying to make a if else endif kinda solution but it does not work.

    <?php if (is_page(Home)): ?>
    <div id="sidebarfront">
    <div id="bannerside">
    <img src="https://gadzilla.dk.linux7.curanetserver.dk/wp-content/uploads/banner.jpg" width="280" height="200" /></div>
            <div id="bannerside"><img src="https://gadzilla.dk.linux7.curanetserver.dk/wp-content/uploads/tilmeldnyhedsbrev_head.png" width="211" height="19" />
                      <p>
                        <input name="textfield" type="text" class="newsmail_text" id="textfield" value="Navn" />
                      </p>
                      <p>
                        <input name="textfield2" type="text" class="newsmail_text" id="textfield2" value="Email" />
                      </p></div>
            <div id="bannerside"><img src="https://gadzilla.dk.linux7.curanetserver.dk/wp-content/uploads/tipenven_head.png" width="105" height="19" />
                      <p>
                        <input name="textfield3" type="text" class="newsmail_text" id="textfield3" value="Dit navn" />
                                      </p>
                      <p>
                          <input name="textfield3" type="text" class="newsmail_text" id="textfield4" value="Din vens navn" />
                      </p>                  <p>
                        <input name="textfield4" type="text" class="newsmail_text" id="textfield5" value="Din vens email" />
                      </p></div>
    <?php else: ?>
    <div id="sidebar">
    <div id="submenu">
      <ul>
        <?php include("submenu.php"); ?>
      </ul>
    </div>
    <?php endif; ?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter gadzilla

    (@gadzilla)

    I found out what was wrong.

    I had to use the <?php if (is_front_page()): ?> instead, since you cannot use <?php if (is_page(Frontpage)): ?> for detecting the front page or home page.

    Also i had to use the <?php wp_reset_query(); ?> before the <?php if (is_front_page()): ?> to make it work.

    Read more about that here: <a′href=”https://www.ads-software.com/support/topic/269988?replies=14″&gt;

    So my code looks like this now:

    `<?php
    /**
    * @package WordPress
    * @subpackage Default_Theme
    */
    ?>
    <?php wp_reset_query(); ?>
    <?php if (is_front_page()): ?>
    <div id=”sidebarfront”>
    <div id=”bannerside”>
    <img src=”https://gadzilla.dk.linux7.curanetserver.dk/wp-content/uploads/banner.jpg&#8221; width=”280″ height=”200″ /></div>
    <div id=”bannerside”><img src=”https://gadzilla.dk.linux7.curanetserver.dk/wp-content/uploads/tilmeldnyhedsbrev_head.png&#8221; width=”211″ height=”19″ />
    <p>
    <input name=”textfield” type=”text” class=”newsmail_text” id=”textfield” value=”Navn” />
    </p>
    <p>
    <input name=”textfield2″ type=”text” class=”newsmail_text” id=”textfield2″ value=”Email” />
    </p></div>
    <div id=”bannerside”><img src=”https://gadzilla.dk.linux7.curanetserver.dk/wp-content/uploads/tipenven_head.png&#8221; width=”105″ height=”19″ />
    <p>
    <input name=”textfield3″ type=”text” class=”newsmail_text” id=”textfield3″ value=”Dit navn” />
    </p>
    <p>
    <input name=”textfield3″ type=”text” class=”newsmail_text” id=”textfield4″ value=”Din vens navn” />
    </p> <p>
    <input name=”textfield4″ type=”text” class=”newsmail_text” id=”textfield5″ value=”Din vens email” />
    </p></div>
    <?php else: ?>
    <div id=”sidebar”>
    <div id=”submenu”>

      <?php include(“submenu.php”); ?>

    </div>
    <?php endif; ?>’

    I hope this can save somebody else some time.

    thanks… did save me quite a headache!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘<?php if (is_page(Home)): ?> problem’ is closed to new replies.