WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have two custom posts, one called "reviews" and another called "guides". I want to display a custom field from the post reviews if the title of the two matches.

Something like this: (I am not good with codes, this was the way I found to explain how I think it should be)

<? php
if ('$post_title' 'guides' == '$post_title' 'reviews') {
 echo ('custom_field' 'reviews');
 return __(no details);
share|improve this question

You don't mention exactly if you are referring to the default Custom Fields. If so, the solution bellow doesn't apply.

But, much better than the default, is to create a Custom Meta Box where you present your Custom Field(s).

The Codex has an example in Function_Reference/add_meta_box.
These can also be useful:

Check the comments in the code and also the message that's printed in the MB.

add_action( 'add_meta_boxes', 'add_meta_box_wpse_75963' );

function add_meta_box_wpse_75963() 
    // This prevents the code from going further if not in the correct post type
    global $post;
    if( 'reviews' != $post->post_type )

    // Check if the other post type has a post with the same title
    // If it doesn't, bail out
    $other_page = get_page_by_title( $post->post_title, OBJECT, 'guides' );
    if( !$other_page )

    // We are in the correct post_type (reviews)
    // and there is another post in "guides" with the same title
        __( 'Custom Field' ), 

function display_meta_box_wpse_75963() 
    echo "Insert custom field procedures here.";
    echo "Also create the appropriate <code>add_action( 'save_post', 'callback');</code>";
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.