Reputation: 1137
Is there a way to make a static front-page made up of child pages, surrounded by sections, like this:
Front Page
<div class="main">
Parent Start
<section id="<section title>">
Child Content
</section>
<section id="<section title>">
Child Content
</section>
<section id="<section title>">
Child Content
</section>
Parent End
</div>
I was thinking the section id could be added from the menu settings?
Appreciate if anybody could point me in the right direction!
SOLUTION
$args = array(
'posts_per_page' => -1,
'meta_key' => 'priority',
'orderby' => 'meta_value_num',
'order' => 'ASC',
'post_type' => 'page',
'post_status' => 'publish',
'meta_query' => array(
array(
'key' => 'add_to_front_page',
'value' => 'Yes',
'compare' => '=',
),
),
);
$pages = get_posts( $args );
foreach ( $pages as $page ) {
$title = $page->post_title;
$content = wpautop( $page->post_content );
}
priority
and add_to_front_page
are custom fields!
Upvotes: 0
Views: 47
Reputation: 326
Use WP_Query.
<div class="main">
<?php
$args = array(
'posts_per_page' => -1,
'meta_key' => 'priority',
'orderby' => 'meta_value_num',
'order' => 'ASC',
'post_type' => 'page',
'post_status' => 'publish',
'meta_query' => array(
array(
'key' => 'add_to_front_page',
'value' => 'Yes',
'compare' => '=',
),
),
);
$query = new WP_Query( $args );
while($query->have_posts() ):
$query->the_post() : ?>
<section id="<section title>">
<?php the_title();
the_content(); ?>
</section>
<?php
endwhile;
wp_reset_postdata();
?>
</div>
Upvotes: 1