• Resolved inactive

    (@nurdanucergmailcom)


    Hello,

    I have been trying to display additional meta data next to the candidate connection title.

    Here’s my code (I have a meta field with a meta key of “OriginalID” in my post_meta table):

    function append_info_to_candidate_title( $title, $ctype, $post ) {
    	if ( 'tweets_to_posts' == $ctype->name && 'tweet' == $post->post_type ) {
    		$title .= " (" . $post->OriginalID . ")";
    	}
    
    	return $title;
    }
    add_filter( 'p2p_candidate_title', 'append_info_to_candidate_title', 10, 3 );

    Even if I ask the function just to add a static text string to the candidate title, I get nothing.

    Any pointers are very much appreciated, thanks.

    http://wordpress.org/extend/plugins/posts-to-posts/

Viewing 1 replies (of 1 total)
  • Thread Starter inactive

    (@nurdanucergmailcom)

    Posting my solution in case it helps someone.

    It turns out that the function parameter order creates the problem. The order is supposed to be:

    function append_info_to_candidate_title( $title, $post, $ctype )

    and not:

    function append_info_to_candidate_title( $title, $ctype, $post )

    Here’s how I got the candidate title to display post author and post date:

    // add author + date to the title
    function append_author_to_candidate_title( $title, $post, $ctype ) {
    	if ( 'tweets_to_posts' == $ctype->name && 'tweet' == $post->post_type ) {
    
    		$user_info = get_userdata($post->post_author);
    		$tweet_person = $user_info-> display_name;
    		$tweet_date = get_the_time('j/m/Y G:i', $post->ID);
    		$title .= " - <span style='color: red;'>". $tweet_person . "</span> - <span style='color: blue;'>" . $tweet_date . "</span>";
    	}
    	return $title;
    }
    add_filter( 'p2p_candidate_title', 'append_author_to_candidate_title', 10, 3 );
Viewing 1 replies (of 1 total)

The topic ‘p2p_candidate_title returns nothing?’ is closed to new replies.