使用jQuery加载Wordpress页面,使网站成为1页
我已经创建了一个wordpress网站,至少有6-7页不同的内容。我已经使它的行为像单页网站使用自定义模板与固定的页面数与下面的代码使用jQuery加载Wordpress页面,使网站成为1页,jquery,wordpress,singlepage,Jquery,Wordpress,Singlepage,我已经创建了一个wordpress网站,至少有6-7页不同的内容。我已经使它的行为像单页网站使用自定义模板与固定的页面数与下面的代码 $args = array( 'post_type' => 'page', 'orderby' => 'menu_order', 'order' => 'asc', 'post__in' => array(10,12,202,14,16,18,208,20) //list of page_id
$args = array(
'post_type' => 'page',
'orderby' => 'menu_order',
'order' => 'asc',
'post__in' => array(10,12,202,14,16,18,208,20) //list of page_ids
);
$page_query = new WP_Query( $args );
//echo 'Post Id='.$post->ID;
if( $page_query->have_posts() ) :
echo '<div class="pages-on-page">';
//print any general title or any header here//
while( $page_query->have_posts() ) : $page_query->the_post();
echo '<div class="page-on-page" id="page_id-' . $post->ID . '">';
$content_post = get_post($post->ID);
$content = $content_post->post_content;
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]>', $content);
echo $content;
//print any output you want per page//
echo '</div>';
endwhile;
echo '</div>';
$args=array(
“post_type”=>“page”,
'orderby'=>'菜单\u顺序',
“订单”=>“asc”,
'post_uin'=>数组(10,12202,14,16,18208,20)//页面ID列表
);
$page\u query=新的WP\u查询($args);
//回显“Post Id=”。$Post->Id;
如果($page\u query->have\u posts()):
回声';
//在此处打印任何常规标题或标题//
而($page\u query->have\u posts()):$page\u query->the\u post();
回声';
$content\u post=get\u post($post->ID);
$content=$content\u post->post\u content;
$content=apply_过滤器('the_content',$content);
$content=str_replace(']]>',']]',$content);
echo$内容;
//打印每页所需的任何输出//
回声';
结束时;
回声';
在我不添加新页面显示之前,它工作正常。有谁能建议我如何使其动态化,以便我不必在数组中给出固定数量的页面id。要列出所有页面的id,可以使用
wp\u list\u pull
,如下所示
$pages = get_pages(
array (
'parent' => 0, // replaces 'depth' => 1,
'exclude' => '3,5,11'
)
);
$ids = wp_list_pluck( $pages, 'ID' );
现在
这是否会在wp admin中按指定顺序提供所有页面的内容?因为它只会更改页面id为的手动类型数组,所以应该尝试一下这是否有效。正如我所料。我已经接受了你的回答。
'post__in' => $ids