首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将内容添加到wordpress最近的文章之上

将内容添加到wordpress最近的文章之上
EN

Stack Overflow用户
提问于 2015-11-26 20:43:59
回答 1查看 91关注 0票数 0

我正在尝试插入元滑块,以显示在我的文章上方的wordpress。

我正确地将代码插入到循环上方的主题index.php文件中。它工作正常,但它也显示在边栏的顶部以及,我希望它就在上面的帖子。

对我怎么做有什么建议吗?在循环中我需要插入它的哪个位置?

这是我有的东西

代码语言:javascript
复制
<?php
/**
 * The main template file
 *
 * @package SimpleMag
 * @since   SimpleMag 1.0
**/
get_header();
global $ti_option;
?>

<?php $archive_sidebar = get_field( 'page_sidebar', get_option('page_for_posts') ); ?>

    <section id="content" role="main" class="clearfix animated">


<?php 
    echo do_shortcode("[metaslider id=437]"); 
?>

        <?php if ( $ti_option['posts_page_title'] == 'full_width_title' ) : ?>
        <header class="entry-header page-header">
            <div class="wrapper title-with-sep page-title">
                <h1 class="entry-title">
                    <?php
                    $posts_page_id = get_option( 'page_for_posts' );
                    echo get_the_title( $posts_page_id );
                    ?>
                </h1>
            </div>
        </header>
        <?php endif; ?>

        <div class="wrapper">
        <?php
        // Enable/Disable sidebar based on the field selection
        if ( ! $archive_sidebar || $archive_sidebar == 'page_sidebar_on' ):
        ?>
            <div class="grids">
                <div class="grid-8 column-1">
        <?php endif; ?>

                <?php if ( $ti_option['posts_page_title'] == 'above_content_title' ) : ?>
                <header class="entry-header page-header">
                    <div class="title-with-sep page-title">
                        <h1 class="entry-title">
                            <?php
                            $posts_page_id = get_option( 'page_for_posts' ); 
                            echo get_the_title( $posts_page_id ); 
                            ?>
                        </h1>
                    </div>
                </header>
                <?php endif; ?>

                <div class="grids <?php echo $ti_option['posts_page_layout']; ?> entries">
                    <?php 
                    if ( have_posts() ) : while ( have_posts()) : the_post();
                        get_template_part( 'content', 'post' );
                    endwhile;
                    ?>
                </div>

                <?php ti_pagination(); ?>

                <?php else : ?>

                <p class="message">
                    <?php _e( 'Sorry, no posts were found', 'themetext' ); ?>
                </p>

                <?php endif;?>

                <?php
                // Enable/Disable sidebar based on the field selection
                if ( ! $archive_sidebar || $archive_sidebar == 'page_sidebar_on' ):
                ?>
                </div><!-- .grid-8 -->

                <?php get_sidebar(); ?>

            </div><!-- .grids -->
            <?php endif; ?>

        </div><!-- .wrapper -->
    </section><!-- #content -->

<?php get_footer(); ?>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-11-26 21:21:04

只要侧边栏被关闭,你的位置就会很好。当侧栏处于活动状态时,您应该将其放置在<div class="grid-8 column-1">下面。这是页面主区域的开始,在侧边栏旁边。(我猜div使用的是类似于引导的东西,占据了12个可用网格中的8个)。

若要防止将来更新主题以覆盖自定义,如果这实际上是受支持的主题,则还应考虑创建子主题。它非常简单,并在这里解释:Themes

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33946722

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档