Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
发布类型索引为Wordpress首页_Wordpress - Fatal编程技术网

发布类型索引为Wordpress首页

发布类型索引为Wordpress首页,wordpress,Wordpress,如何将帖子类型的索引页作为Wordpress的首页提交?在设置中,Wordpress只允许页面成为首页 Example: Post type: Book Post type slug: books Post type index: archieve-books.php 我需要mydomain.com/books作为mydomain.com的首页 谢谢。这可以通过自定义page.php模板轻松完成。默认情况下,不能将存档页设置为首页,只能设置页面模板 有关参考,请参阅 要创建自定义首页,请复制p

如何将帖子类型的索引页作为Wordpress的首页提交?在设置中,Wordpress只允许页面成为首页

Example:
Post type: Book
Post type slug: books
Post type index: archieve-books.php
我需要mydomain.com/books作为mydomain.com的首页
谢谢。

这可以通过自定义page.php模板轻松完成。默认情况下,不能将存档页设置为首页,只能设置页面模板

有关参考,请参阅

要创建自定义首页,请复制page.php模板并在页面循环之后将其重命名为front-page.php,添加自定义查询以调用自定义帖子类型

<?php
$paged = ( get_query_var('page') ) ? get_query_var('page') : 1;
$args = array(
    'post_type' => 'books',
    'posts_per_page' => 5,
    'paged' => $paged
);
// The Query
$the_query = new WP_Query( $args );

// The Loop
if ( $the_query->have_posts() ) {
    echo '<ul>';
    while ( $the_query->have_posts() ) {
        $the_query->the_post();
        echo '<li>' . get_the_title() . '</li>';
    }
    echo '</ul>';

next_posts_link( 'Older Entries', $the_query->max_num_pages );
previous_posts_link( 'Newer Entries' );

} else {
    // no posts found
}
/* Restore original Post Data */
wp_reset_postdata();
?>

您现在可以选择此页面作为静态首页。

请为我澄清。。是否要在头版显示自定义帖子类型手册中的分页帖子?您是否愿意编辑模板文件?
Example:
Post type: Book
Post type slug: books
Post type index: archieve-books.php