if is_front_page in wordpress

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
seandisanti
php-forum Fan User
php-forum Fan User
Posts: 974
Joined: Mon Oct 01, 2012 12:32 pm

Wed Oct 21, 2015 4:39 pm

One way of many would be:

Code: Select all

<?php
$header = is_home() ? '' : 'sinform';
get_header($header);
?>


seandisanti
php-forum Fan User
php-forum Fan User
Posts: 974
Joined: Mon Oct 01, 2012 12:32 pm

Wed Oct 21, 2015 5:14 pm

Your best bet may just to evaluate the request parameters to determine what page you're on then. It's been a while since i've done anything with wordpress but I'll spin one up real quick to help you get it sorted, PM me specifics, namely the version you're using and the theme

seandisanti
php-forum Fan User
php-forum Fan User
Posts: 974
Joined: Mon Oct 01, 2012 12:32 pm

Wed Oct 21, 2015 6:16 pm

ok, in looking at the documentation on https://codex.wordpress.org/Function_Re ... front_page and https://codex.wordpress.org/Function_Reference/is_home I think I've got a little insight and can avoid installing it myself. Regardless of whether you've got your initial landing page set to be a posts page or a static front page, is_front_page() should return true on the page designated as the the front page. is_home will return true on the posts index page whether it's set as the front page or not. get_option( 'page_on_front' ) will give you the id of the designated front page where is_front_page() will return true. The documentation on the is_home link looks to spell it out the best.

Post Reply