Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Let's see if anyone knows how to accomplish the following: I have a custom field, which is a textarea where the user can enter any text. The idea is that if a page is filled in that field, the entered content appears on all child pages.

CASE 1

  • Page 1
  • Page 1.1 (the user fills out the custom field and displays the
    content)
  • Page 1.1.1 (displays the contents of the field completed on Page 1.1)
  • Page 1.1.2 (displays the contents of the field completed on Page 1.1)
  • Page 1.1.3 (displays the contents of the field completed on Page 1.1)

CASE 2

  • Page 1 (the user fills out the custom field and displays the content)
  • Page 1.1 (displays the contents of the field completed on Page 1)
  • Page 1.2 (the user fills in the field, so it inherits from Page 1.1, but shows your own)
  • Page 1.2.1 (displays the contents of the field completed on Page 1.2)

I hope I explained well with the examples of what I get.

Thank you in advance.

share|improve this question
add comment

1 Answer

$value = get_post_meta($post->post_parent,'your fields name',true);
if(!empty($value)){
    // display the value
    echo $value;
}
share|improve this answer
add comment

Your Answer

 
discard

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.