Support » Everything else WordPress » the_title filter

  • Hi,
    in my plugin “Bookable Events” I’ve used the ‘the_title’ filter for adding the ‘bookable event’ label to the title of a ‘bookable’ post, but this label appears also in the ‘Last comment’ widget for not bookable post.
    The code is:

    function add_label_to_post_title( $title = '' ) {
    	if ( is_bookable() ) return $title." <div class='redtext'>".__("bookable event", 'bookable-events')."</div>";
    	else return $title;
    }
    
    function is_bookable() {
    	global $bookable_key;
    	global $bookable;
    	$meta = get_post_custom();
    	$meta_book_event = $meta[$bookable_key][0];
    
    	if ( $meta_book_event != '' ) return $bookable = true;
    	else return $bookable = false;
    }
    
    add_filter( 'the_title', 'add_label_to_post_title' );

    Any suggestions?

  • The topic ‘the_title filter’ is closed to new replies.