Support » Plugin: Posts 2 Posts » Alternative to 'p2p_candidate_title'?

  • blurby

    (@nurdanucergmailcom)


    Hello,

    I need to display post author and post date in addition to the title when I am creating/searching for connections. (I need to know the date/author before I relate one item to the other)

    I believe “p2p_candidate_title” is what I need, but I found out that it’s not yet available in the current release.

    Any alternatives to solving this issue? I store all the info I need in the post_excerpt field and it would suffice if I can simply display post excerpt instead of the post title while creating connections.

    Thanks.

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

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author scribu

    (@scribu)

    Just released version 1.6, which contains the ‘p2p_candidate_title’ filter.

    blurby

    (@nurdanucergmailcom)

    Scribu, once again, you are a star!

    Thank you for all your hard work!

    blurby

    (@nurdanucergmailcom)

    Quick question:

    Am I using the filter properly? I am not getting anything next to the candidate title:

    function append_date_to_candidate_title( $title, $ctype, $post ) {
    	if ( 'tweets_to_posts' == $ctype->name && 'post' == $post->post_type ) {
    		$title .= " (" . $post->_wp_page_template . ")";
    		$title .= " (" . $post->post_author . ")";
    		$title .= " (" . $post->post_date . ")";
    	}
    
    	return $title;
    }
    
    add_filter( 'p2p_candidate_title', 'append_date_to_candidate_title', 10, 3 );

    Thanks!

    blurby

    (@nurdanucergmailcom)

    Update:

    I have realized the field has to come from the meta table, so I have updated the code accordingly, but to no avail.

    Here’s my code (I have a meta field titled “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.

    Thanks Scribu!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Alternative to 'p2p_candidate_title'?’ is closed to new replies.