如何使用全长的上半部分内容和下半部分内容是带有侧边栏的内容?

时间:2013-11-13 作者:winresh24

有人能帮我解决这个问题吗?虽然很简单,但我只是wordpress的新手?

现在,我正在使用带有侧栏的主题的默认模板。所以我想做的是在页面内容上方,菜单下方是在页面上放置内容,但仅在主页中,我不想在整个页面上看到它。

对不起,我的英语很难用英语解释,希望你能理解我想说的。

这是当前站点http://ftcanada.com/这是我想插入的内容http://awesomescreenshot.com/02a1ycnn26

请帮帮我。。。

以下是内容。php

当我在文章id上方插入代码时,内容会出现在每个页面中。我想做的是在主页上显示它。

<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    <header class="entry-header">
        <?php if ( is_sticky() ) : ?>
            <hgroup>
                <h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( \'Permalink to %s\', \'catchbox\' ), the_title_attribute( \'echo=0\' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
                <h3 class="entry-format"><?php _e( \'Featured\', \'catchbox\' ); ?></h3>
            </hgroup>
        <?php else : ?>
        <h1 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( \'Permalink to %s\', \'catchbox\' ), the_title_attribute( \'echo=0\' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h1>
        <?php endif; ?>

        <?php if ( \'post\' == get_post_type() ) : ?>
            <div class="entry-meta">
                <?php catchbox_posted_on(); ?>
                <?php if ( comments_open() && ! post_password_required() ) : ?>
                    <span class="sep sep-comment"> &mdash; </span>
                    <span class="comments-link">
                        <?php comments_popup_link(__(\'No Comments &darr;\', \'catchbox\'), __(\'1 Comment &darr;\', \'catchbox\'), __(\'% Comments &darr;\', \'catchbox\')); ?>
                    </span>
                <?php endif; ?>
            </div><!-- .entry-meta -->
        <?php endif; ?>
    </header><!-- .entry-header -->

     <?php 
        $options = catchbox_get_theme_options();
        $current_content_layout = $options[\'content_layout\'];
        $catchbox_excerpt = get_the_excerpt();

    if ( is_search() ) : // Only display Excerpts for Search ?>
        <div class="entry-summary">
            <?php the_excerpt(); ?>
        </div><!-- .entry-summary -->
    <?php elseif ( $current_content_layout==\'excerpt\' && !empty( $catchbox_excerpt ) ) : // Only display Featured Image and Excerpts if checked in Theme Option ?>
        <div class="entry-summary">
            <?php if( has_post_thumbnail() ):?>
                <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( \'Permalink to %s\', \'catchbox\' ), the_title_attribute( \'echo=0\' ) ); ?>" rel="bookmark">
                    <?php the_post_thumbnail(\'featured-slider\'); ?>
                </a>
            <?php endif; ?>
            <?php the_excerpt(); ?>
        </div><!-- .entry-summary -->
    <?php else : ?>
    <div class="entry-content">
        <?php the_content( __( \'Continue reading <span class="meta-nav">&rarr;</span>\', \'catchbox\' ) ); ?>
        <?php wp_link_pages( array( 
            \'before\'        => \'<div class="page-link"><span class="pages">\' . __( \'Pages:\', \'catchbox\' ) . \'</span>\',
            \'after\'         => \'</div>\',
            \'link_before\'   => \'<span>\',
            \'link_after\'    => \'</span>\',
        ) ); 
        ?>
    </div><!-- .entry-content -->
    <?php endif; ?>

    <footer class="entry-meta">
        <?php $show_sep = false; ?>
        <?php if ( \'post\' == get_post_type() ) : // Hide category and tag text for pages on Search ?>
        <?php
            /* translators: used between list items, there is a space after the comma */
            $categories_list = get_the_category_list( __( \', \', \'catchbox\' ) );
            if ( $categories_list ):
        ?>
        <span class="cat-links">
            <?php printf( __( \'<span class="%1$s">Posted in</span> %2$s\', \'catchbox\' ), \'entry-utility-prep entry-utility-prep-cat-links\', $categories_list );
            $show_sep = true; ?>
        </span>
        <?php endif; // End if categories ?>
        <?php
            /* translators: used between list items, there is a space after the comma */
            $tags_list = get_the_tag_list( \'\', __( \', \', \'catchbox\' ) );
            if ( $tags_list ):
            if ( $show_sep ) : ?>
        <span class="sep"> | </span>
            <?php endif; // End if $show_sep ?>
        <span class="tag-links">
            <?php printf( __( \'<span class="%1$s">Tagged</span> %2$s\', \'catchbox\' ), \'entry-utility-prep entry-utility-prep-tag-links\', $tags_list );
            $show_sep = true; ?>
        </span>
        <?php endif; // End if $tags_list ?>
        <?php endif; // End if \'post\' == get_post_type() ?>

        <?php if ( comments_open() ) : ?>
        <?php if ( $show_sep ) : ?>
        <span class="sep"> | </span>
        <?php endif; // End if $show_sep ?>
        <span class="comments-link"><?php comments_popup_link( \'<span class="leave-reply">\' . __( \'Leave a reply\', \'catchbox\' ) . \'</span>\', __( \'<b>1</b> Reply\', \'catchbox\' ), __( \'<b>%</b> Replies\', \'catchbox\' ) ); ?></span>
        <?php endif; // End if comments_open() ?>

        <?php edit_post_link( __( \'Edit\', \'catchbox\' ), \'<span class="edit-link">\', \'</span>\' ); ?>
    </footer><!-- #entry-meta -->
</article><!-- #post-<?php the_ID(); ?> -->
谢谢

1 个回复
SO网友:s_ha_dum

您所需要做的就是将附加内容包装在一个条件中,以便它只显示在您需要的地方。你可能想要is_home() (用于博客帖子索引)或is_front_page() (对于网站首页),如下所示:

<?php
if (is_home()) {
  // your addition content
} ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

结束

相关推荐

FILE_GET_CONTENTS_CURL拉取错误的值

我正在使用file\\u get\\u contents\\u curl获取facebook喜欢的帖子,并将其存储在我的数据库中。 $fb = json_decode(file_get_contents_curl(\'http://graph.facebook.com/?id=\'.get_permalink($post->ID))); if( !isset( $fb->likes) && isset($fb->shares) )