Function !is_front_page not working
-
Hi!
I am trying to add a span to blog post titles, based upon their category on the website and I don’t want it to show up in the home page in the widgets section at the bottom. Here is my code:
—
add_filter( ‘the_title’, ‘my_modify_title’, 10, 2 );
function my_modify_title( $title, $id ) {
if( in_category( ‘Fitness’, $id ) ) {
$title = ‘<span class=”fitness”></span> ‘ . $title;
} else if( in_category( ‘Recipe’, $id ) ) {
$title = ‘<span class=”recipe”></span> ‘ . $title;
} else if( in_category( ‘Life etc’, $id ) ) {
$title = ‘<span class=”life”></span> ‘ . $title;
} else if( in_category( ‘Soul’, $id ) ) {
$title = ‘<span class=”soul”></span> ‘ . $title;
}
return $title;
}—
I tried adding:
!is_front_page() to the if and it isn’t working.
add_filter( ‘the_title’, ‘my_modify_title’, 10, 2 );
function my_modify_title( $title, $id ) {
if( !is_front_page() && in_category( ‘Fitness’, $id ) ) {
$title = ‘<span class=”fitness”></span> ‘ . $title;
} else if( !is_front_page() && in_category( ‘Recipe’, $id ) ) {
$title = ‘<span class=”recipe”></span> ‘ . $title;
} else if( !is_front_page() && in_category( ‘Life etc’, $id ) ) {
$title = ‘<span class=”life”></span> ‘ . $title;
} else if( !is_front_page() && in_category( ‘Soul’, $id ) ) {
$title = ‘<span class=”soul”></span> ‘ . $title;
}
return $title;
}—
Please let me know if I’m doing something wrong here…
The website is currently at: http://utopiandesigns.ca/barlinfitness/
The topic ‘Function !is_front_page not working’ is closed to new replies.