New answers tagged wp-list-pages
Not so hard as you expected. Try this: global $wpdb; $sql = "SELECT post_title, meta_value FROM $wpdb->posts a JOIN $wpdb->postmeta b ON a.ID = b.post_id WHERE a.post_type = 'page' AND a.post_status = 'publish' AND b.meta_key = '_wp_page_template' "; $pages = $wpdb->get_results($sql); echo '<pre>'; print_r($pages); echo ...
It looks like the problem is with your IF statement. if($post->ID = 142) should be if($post->ID == 142) (notice the 2 equals signs) Otherwise you are just resetting the variable $post->ID to 142
Basically you want to display a menu of child pages of "Sevice One" if you are in any child page of "Service One", a menu of child pages of "Service Two" if you are in any chiild page of "Service Two", and so on. This can be done with the child_of argument of wp_list_pages. We can fill this parameter dynamically using get_post_ancestors for current page and ...
Top 50 recent answers are included