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.

I've got 3 header.php files and 1 detects whether their either on page 1 or page 2. I have a custom meta box thats outputting the results onto each header - that all works fine.

However when I go a page deeper the meta box information isn't showing, I've tried various if statements but nothing shows up.

Any help would be great.

my header output looks like:

<?php
global $post;
$header_meta = get_post_meta($post->ID, 'page-header-meta', true);
if( isset( $header_meta ) ) {
echo '<h1>' . $header_meta . '</h1>';
}
else {
    echo '<h1>Knowledgebase</h1>';
}

?> 
share|improve this question

1 Answer 1

up vote 0 down vote accepted
global $post;
$header_meta = get_post_meta($post->ID, 'page-header-meta', true);
if( isset( $header_meta ) ) {
echo '<h1>' . $header_meta . '</h1>';
}
else {
    echo '<h1>Knowledgebase</h1>';
}

What this portion of code does is it checks the 'page-header-meta' value according to the page being displayed. IF your parent page has the metavalue set then the header will display. Similarly for the child pages also you need to set the meta value to display the particular header.

share|improve this answer
    
how do i set it for child pages? –  user1888564 Jun 7 '13 at 13:17
    
don't you have the same metabox in the "Add New" child page ?? –  suvajit Jun 7 '13 at 13:18
    
not sure what you mean by "Add New"? –  user1888564 Jun 7 '13 at 13:22
    
How are you adding the child pages? –  suvajit Jun 7 '13 at 13:28
    
inside the admin panel - think I've managed to solve it via the get_queried_object(); thanks! –  user1888564 Jun 7 '13 at 13:37

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.