News Update :
Home » » Condition logique selon la page - If is home page ... Else

Condition logique selon la page - If is home page ... Else

By: Unknown on Tuesday 10 February 2015 | 15:54

When we built a theme it is always better to have the warning possible page. For simplicity above all . When returns to a website after a while there is much more easily.

So for example, instead of a different footer to the home page and interior pages. We can only use conditions, such as:

 




If this is the home page:

Do this : ... .

If this is not the home page

Do this : ... ..

If not you need to create a new file , for example footer- home.php . For maintenance or modifications it complicates our lives and we can create errors by changing one but not the other.

Example:

<? php
if ( is_front_page ( ) && is_home ()) {
  // Default homepage
} Elseif ( is_front_page ()) {
  // Static homepage
} Elseif ( is_home ()) {
  // Blog page
} Else {
  // everything else
}
? >


If you want to code with HTML:

<? php if ( is_front_page ()) : ?>

<img src = " <? php echo get_stylesheet_directory_uri () ;?> / images / logo- accueil.png " width = " 326 " height = " 184 " alt = " Logo " />
<? php endif ; ? >



If this is not the home page (must be added the exclamation point)

< ? php if ( is_front_page ( !)) : ? >

<img src = " <? php echo get_stylesheet_directory_uri () ;?> / images / logo- diane - limoges -inner - en.png " width = " 263 " height = " 162 " alt = " Logo Diane Limoges " />
<? php endif ; ? >



Conditions in the footer

I have not done further research but if it does not work in the footer , you must reset the Global value if you use this function in the footer:
wp_reset_query ()

? php wp_reset_query (); ? >
<? php if ( is_front_page ()) : ?>

<p > What Works </ p>

<? php endif ; ? >
 
Contact Us | Privacy policy | Term of use | Advertise with Us | Site map
Copyright © 2011. Blogging Brain . All Rights Reserved.
Design Template by Blogging Brain | | Powered by Blogger