You could use get_pages
to do this, like so:
<?php
$args = array(
'post_type' => 'page',
'child_of' => 7,
);
$postobj = get_pages($args);
foreach($postobj as $item){
$dir = get_bloginfo('template_directory'); // Theme directory
$title = $item->post_title;
$parent = $item->post_parent;
$id = $item->guid;
$name = $item->post_name;
Once you get to here, you can pull out your custom fields and put them into variables.
$model_number = get_post_meta($item->ID, 'model_number', true);
I would use an if
statement of some kind to build those top headings. For instance you could do:
if($model_number == true){
echo stuff;
} else {
echo other stuff;
}
}
?>
It’s rough, but I think this could get you quite a long ways. Essentially, you’re programmatically building your headings and returning everything to get printed. The key is formatting everything and getting your conditions set up right.