如何在Bootstrap WordPress中添加2列博客文章

昌丹

请帮忙。我想为Bootstrap WordPress主题添加2列博客文章。我只能动态地上半场。

我只想在首页上显示。我对自举网格不太了解,但是不知道在主页上动态添加WordPress。

主页截图

Index.php

<?php
/**
 * The main template file
 *
 * This is the most generic template file in a WordPress theme
 * and one of the two required files for a theme (the other being style.css).
 * It is used to display a page when nothing more specific matches a query.
 * E.g., it puts together the home page when no home.php file exists.
 *
 * @link https://developer.wordpress.org/themes/basics/template-hierarchy/
 *
 * @package bootstrap
 */

get_header();
?>

<div id="primary" class="content-area col-xs-6 col-sm-6">
    <main id="main" class="site-main">
        <?php
        if ( have_posts() ) :
            if ( is_home() && ! is_front_page() ) :
        ?>
                <header>
                    <h1 class="page-title screen-reader-text">
                        <?php single_post_title(); ?>
                    </h1>
                </header>
            <?php
            endif;

            /* Start the Loop */
            while ( have_posts() ) :
                the_post();

                /*
                * Include the Post-Type-specific template for the content.
                * If you want to override this in a child theme, then include a file
                * called content-___.php (where ___ is the Post Type name) and that will be used instead.
                */
                get_template_part( 'template-parts/content', get_post_type() );

            endwhile;

            the_posts_navigation();

        else :

            get_template_part( 'template-parts/content', 'none' );

        endif;
        ?>

    </main><!-- #main -->
</div><!-- #primary -->

<?php
get_footer();
卡西夫·拉菲克(Kashif Rafique)

尝试这个。

Index.php

<?php
/**
 * The main template file
 *
 * This is the most generic template file in a WordPress theme
 * and one of the two required files for a theme (the other being style.css).
 * It is used to display a page when nothing more specific matches a query.
 * E.g., it puts together the home page when no home.php file exists.
 *
 * @link https://developer.wordpress.org/themes/basics/template-hierarchy/
 *
 * @package bootstrap
 */

get_header();
?>

<div id="primary" class="content-area col-md-8">
    <main id="main" class="site-main">
        <?php
        if ( have_posts() ) :
            if ( is_home() && ! is_front_page() ) :
        ?>
                <header>
                    <h1 class="page-title screen-reader-text">
                        <?php single_post_title(); ?>
                    </h1>
                </header>
            <?php
            endif;

            /* Start the Loop */ ?>
            <div class="row">
                <?php
                while ( have_posts() ) :
                    the_post(); ?>
                    <div class="col-xs-12 col-sm-6">
                        <?php
                        /*
                        * Include the Post-Type-specific template for the content.
                        * If you want to override this in a child theme, then include a file
                        * called content-___.php (where ___ is the Post Type name) and that will be used instead.
                        */
                        get_template_part( 'template-parts/content', get_post_type() );
                        ?>
                    </div>

                <?php endwhile; ?>
            </div>
            <?php the_posts_navigation();

        else :

            get_template_part( 'template-parts/content', 'none' );

        endif;
        ?>

    </main><!-- #main -->
</div><!-- #primary -->

<?php
get_footer();

结果

在此处输入图片说明

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

如何在博客文章详细信息中添加表单?

如何在Slim 2中对博客文章进行分页?

如何在版本4.8.2中解决博客文章的WordPress文章永久链接结构?

如何在博客文章中包含链接

如何在外部 html/php 网站中显示 wordpress 博客文章类别

如何在wordpress的标签中添加博客条目?

如何在 Wordpress 博客中添加苹果触摸图标?

如何在免费博客中添加wordpress插件?

如何在 meezanine CMS 中为博客文章添加更多字段?

如何在Wordpress博客文章上显示作者?

如何使用perl正则表达式从wordpress博客中解析文章?

如何在博客文章中嵌入代码和图像

我将如何添加标签以在MVC应用程序中对博客文章进行分区?

如何自动将博客文章作者添加到成员列表中?

如何从博客文章页面中删除 Yoast

如何在Wordpress中显示博客页面?

如何在Bootstrap中叠加?

如何在博客中添加欢迎声音?

如何在Bootstrap Vue表中动态添加列

如何在Bootstrap 4中的列之间添加空间

如何在Bootstrap 3中添加10个相等的列

如何在Bootstrap表中添加Bootstrap按钮

如何从WordPress博客文章页面中排除类别

如何在Bootstrap 3中重叠列?

如何在单个WordPress帖子前添加博客目录?

如何在不登录的情况下向博客文章添加“赞”功能

我应该如何在 django-allauth 的注册表单中添加一个字段?文档 vs Stackoverflow vs 博客文章

如何在Bootstrap输入的右侧添加图标?

如何在Bootstrap中更改btn颜色