Skip to content
WJunction - Webmaster Forum

need help with my script, adding some words in all posts tittle

Status
Not open for further replies.

widel

Established Member
290
2011
64
I want to add some words "[Rock]" before the tittle in specific category (rock). I have that function:

Code:
function suppress_if_Rock($title, $id) {
    if (in_category('Rock', $id)) {
		return '[Rock] '.$title;
    }
    return $title;
}
add_filter('the_title', 'suppress_if_Rock', 10, 2);

But when i add this to function.php I getting blank page on my site, what is wrong with this code?

Thanks for support.
 

2 comments

Tested & Working

append below code to your functions.php
Code:
<?php
function suppress_if_Rock($title) {
    if ( in_category( 'Rock' )){
        return '[Rock] '.$title;
    }
    else{
    return $title;
    }
}
add_filter('the_title', 'suppress_if_Rock');
?>
Make sure to append it after '?> ' tag in functions.php
 
Status
Not open for further replies.

About the author

W
Established Member · Joined
290
Messages
64
Reactions
28
Points
Grow your business

Advertise on WJunction

Connect with an established international community of webmasters, hosting providers, developers and online entrepreneurs.

  • Premium & Premium+ Sticky
  • Dedicated section banners
  • Site-wide banner advertising
Explore advertising options
Back
Top Bottom