如何在word-press中创建两个单独的博客文章页面



我有博客和案例页面的网站,如 example.com/blog 和 example.com/cases,目前我已经安装了两个带有专用数据库的wordpress,这是正确的方法吗?是否有任何选项可以创建两个博客文章页面,我不想在博客部分显示案例帖子,而在案例中显示博客部分文章,两者都不同,当用户查看它时应该在子目录下。就像 example.com/blog/post-1 和 example.com/cases/post-23 一样。

至少有办法合并数据库?

谢谢

用于在"案例"页面中显示最近的 5 篇帖子。创建一个新的 case.php 页面,并将以下代码行放在此 PHP 页面中,并将其放入您的主题目录中。并为"案例"WordPress页面分配页面模板。

<?php
/* Template Name: Cases */
$args = array(
        'post_type' => array( 'cases' ),
        'posts_per_page' => 5,
    );
$my_query = new WP_Query( $args );
if( $my_query->have_posts() ) :
while ( $my_query->have_posts() ) : $my_query->the_post(); ?>
    <div class="smal-sec">
        <h3><?php the_title();?></h3>
        <?php the_content();?>
    </div>
<?php
endwhile;
endif;
wp_reset_query();  // Restore global post data stomped by the_post().
?>

最新更新