WordPress Custom Fields
-
Hi,
Was wondering if someone could help me.
I have a template page that a has a side bar navigation there are going to be multiple pages which use this template. There is also a child pages for each of these pages.
At the top of the sidebar i have some custom fields which are pulled from the parent page. These are working and displaying fine on all the child pages how ever when viewing the parent page the custom fields do not.
Here is my code
<?php $parent = $post->post_parent; $parent_title = get_the_title($parent); $address = $post->post_parent; $address = get_post_meta($address, 'address', true); $phone = $post->post_parent; $phone = get_post_meta($phone, 'phone', true); ?> <h2>ABC <?php echo($parent_title); ?></h2> <?php echo $address ?> <?php echo $phone ?> <?php $current_page = $post->ID; $parent = 1; while($parent) { $page_query = $wpdb->get_row("SELECT post_name, post_parent FROM $wpdb->posts WHERE ID = '$current_page'"); $parent = $current_page = $page_query->post_parent; if(!$parent) $parent_name = $page_query->post_name; } ?> <ul> <li><a href="/<?php echo $parent_name ?>/our-philosophy-and-values">Our Philosophy & Values</a></li> <li><a href="/<?php echo $parent_name ?>/curriculum">Curriculum</a></li> <li><a href="/<?php echo $parent_name ?>/our-centre-director">Our Centre Director</a></li> <li><a href="/<?php echo $parent_name ?>/photo-gallery">Photo Gallery</a></li> <li><a href="/<?php echo $parent_name ?>/our-ero-reports">Our ERO Reports</a></li> <li><a href="/<?php echo $parent_name ?>/policies">Policies</a></li> <li><a href="/<?php echo $parent_name ?>/fees">Fees</a></li> <li><a href="/<?php echo $parent_name ?>/your-first-day">Your First Day</a></li> <li><a href="/<?php echo $parent_name ?>/transitioning">Transitioning</a></li> </ul>
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘WordPress Custom Fields’ is closed to new replies.