WordPress.org

Ready to get started?Download WordPress

Forums

the_title filter (1 post)

  1. sefran
    Member
    Posted 4 years ago #

    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?

Topic Closed

This topic has been closed to new replies.

About this Topic