munzirstudio
Member
Posted 8 months ago #
Hi,
I have a problem here, I'm creating a restaurant directory, instead of typing restaurant word in the end of the restaurant's name for e.g 'Spice and Hot Restaurant' in the title field, can we just put Spice and Hot and we coded the restaurant in a function that echoed whenever the title being requested (in header, in post) wherever possible.
Anybody knew how to do it?
tq
add_filter( 'the_title', 'tcb_cpt_title_prefix', 10, 2);
function tcb_cpt_title_prefix( $title, $post_id ){
if( 'restaurant' == get_post_type($post_id) ) :
return $title . ' Restaurant';
endif;
return $title;
}
munzirstudio
Member
Posted 8 months ago #
thanks a lot TCBarrett, it works..
but there's only one little problem left, how to print the function into the <title> tag, it doesn't appeared in it. maybe something to do with wp_title hook?