Reputation: 1137
How can I add a static front page that will contain other pages placed in sections?
Ex. my static front pages is called Home. In addition to this Home page, I have three other pages: Bio, Music and Contact. All these three pages will each have two custom fields assigned to them: add_to_front_page = (Yes/No) and priority = int.
If add_to_front_page equals Yes. The current page will be added to the static Home page somehow like this:
Static Front Page = Home
<div class="main">
<section id="<page title>">
Bio content <!-- priority 1 -->
</section>
<section id="<page title>">
Music content <!-- priority 2 -->
</section>
<section id="<page title>">
Contact content <!-- priority 3 -->
</section>
</div>
I am thinking about creating a page template that will be used only on the static front page, and I need some guidance on how to make this "page section loop".
I am open to other suggestions to solve this issue, as long as the result remains the same!
Upvotes: 0
Views: 2263
Reputation: 3816
You can get this pages this way:
$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 );
}
And you can place this in front-page.php
, which is the template for the static front-page.
Upvotes: 1