有没有办法制作一个由子页面组成的静态首页,这些页面被部分包围,如下所示:
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>
我在考虑可以从菜单设置添加部分ID吗?
感谢是否有人能指出我正确的方向!
解
$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
和add_to_front_page
是自定义字段!
答案 0 :(得分:1)
使用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>