I’m trying to get if its home page or not. (I mean all kind of home page in wordpress: Default, static, blog). I wrote this code in function.php
file but in all pages I get “not home”!!
JavaScript
x
if ( is_front_page() && is_home() ) {
die("home");
} elseif ( is_front_page() ) {
die("home");
} elseif ( is_home() ) {
die("home");
} else {
die("not home");
}
Advertisement
Answer
Set home page screenshot https://prnt.sc/rbfgy8
Add this code in theme functions.php
JavaScript
//Put the condition in wp_footer hook to see the result
add_action('wp_footer', 'custom_wp_footer_fun');
function custom_wp_footer_fun(){
if ( is_front_page() && is_home() ) {
echo 'home';
} elseif ( is_front_page() ) {
echo 'home';
} elseif ( is_home() ) {
echo 'home';
} else {
echo 'not home';
}
}