WordPress – is_home() not working

For several days now, I have been caught out with the problem that a plugin is not functioning the way it should be.

My problem begun when a Mootools slideshow plugin breaks a jQuery plugin having hide/show functionality. I have searched solutions to prevent this conflict but nothing works. The recommended solution is the jQuery.noConflict() function. It fails to solve the conflict though so I decided to separate the two plugins by having the slideshow on the frontpage and the hide/show on another page. That was when I tried using tried using the is_home and the is_front_page WordPress functions.

I noticed that the is_home and the is_front_page function are not functioning when the jQuery show/hide functionality is not getting triggered to hide the content as expected. The WordPress forum solution is not something I wanted as everything is hard-coded. I need something more dynamic.

I have experimented on some alternatives to is_home() function but if I change my permalinks to SEO friendly URLs, the code breaks again. I was getting desperate until I figured out the function that works on normal or SEO URLs.

/**
* This function is an alternative
* to the built-in WordPress is_home()
* function
*/

function is_home_alternative()
{
   $result = false; 
   if ( basename ( $_SERVER['REQUEST_URI'] ) == basename ( get_bloginfo('wpurl') ) ): 
      $result = true;
   else:
      $result = false;
   endif;
   return $result;
}

If the page displayed is the frontpage or the home page, this statement will be true regardless of the permalink setting of WordPress.

basename ( $_SERVER['REQUEST_URI'] ) == basename ( get_bloginfo('wpurl') )

2192 = 2184 = 2206

About the Author

Ver Pangonilo
A Filipino Engineer, Registered Professional Engineer of Queensland (RPEQ) - Australia and Professional Electrical Engineer (PEE) - Philippines with extensive experience in concept select, front-end engineering, HV & LV detail design, construction and commissioning of Hazardous and Non-Hazardous Area electrical installations in water and waste water pipeline and pumping facilities, offshore platforms, hydrocarbon process plants and pipelines including related facilities. Hazardous area classification and design certification (UEENEEM015B, UEENEEM016B, UEENEEM017B).
Facebook Auto Publish Powered By : XYZScripts.com