首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >the_excerpt();标记不工作

the_excerpt();标记不工作
EN

WordPress Development用户
提问于 2012-04-04 18:13:41
回答 1查看 1.7K关注 0票数 1

我对the_excerpt();标记有问题,我在index.php和archive.php文件中使用了自己的主题。守则如下:

index.php

代码语言:javascript
复制
<?php get_header(); ?>
<section class="center-column">
<?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>
     <!--<?php echo the_permalink(); ?>-->
    <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
        <header>
            <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
            <div class="post-date"><?php the_time(get_option( 'date_format' )); ?></div>
        </header>
        <?php the_excerpt(); ?>
        <footer class="post-footer">
            <div class="categories">Posted in: <?php the_category(', '); ?></div>
            <div class="tags">Tags: <?php the_tags(); ?></div>
        </footer>
    </article>
    <?php endwhile; ?>
    <section class="post-navigation">
        <div class="alignleft">
            <?php next_posts_link('« Older Entries') ?>
        </div>
        <div class="alignright">
            <?php previous_posts_link('Newer Entries »') ?>
        </div>
    </section>
<?php else : ?>
    <article>
        <h3>Not Found</h3>
        <p>Sorry, but you are looking for something that is not available</p>
    </article>
<?php endif; ?>
</section>
<?php get_sidebar(); ?>
<?php get_footer(); ?>

archive.php

代码语言:javascript
复制
<?php get_header(); ?>

<section class="center-column">
    <!-- Archive Heading -->
    <section>
        <h3 id='archive-heading'>
            <?php if (is_category()) { ?>
            Archive for the '<?php single_cat_title(); ?>' Category
            <?php } elseif (is_tag()) { ?>
            Posts Tagged '<?php single_tag_title(); ?>'
            <?php } elseif (is_month()) { ?>
            Archive for <?php echo get_the_date('F Y'); ?>
            <?php } ?>
        </h3>
    </section>
    <!-- End Archive Heading -->

    <!-- Post Excerpt -->
    <?php if (have_posts()) : ?>
        <?php while (have_posts()) : the_post(); ?>
            <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
                <header>
                    <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
                    <div class="post-date"><?php the_time(get_option( 'date_format' )); ?></div>
                </header>
                <?php the_excerpt(); ?>
                <footer>
                    <div class="categories">Posted in:
                        <?php the_category(', '); ?>
                    </div>
                    <div class="tags">Tags:
                        <?php the_tags(); ?>
                    </div>
                </footer>
            </article>
        <?php endwhile; ?>
    <?php endif; ?>
</section>
<?php get_sidebar(); ?>
<?php get_footer(); ?>

抱歉,代码太长了。

我不清楚问题究竟在哪里,如果你能提供任何帮助,我将不胜感激。

非常感谢,纳夫

EN

回答 1

WordPress Development用户

回答已采纳

发布于 2012-04-05 02:46:22

感谢您的帮助,特别是@byronyasgur给您的最后一个建议。它帮我修好了。

我使用标记作为内容的输入格式,第一行是HTML注释,后面没有空行。添加了一个空行,修复了它。

摘要:这一行的缺失导致摘录为null。在我的开发系统中确实存在这条blnak线,但在实时系统中却没有。

标价用户注意空白行的需要。

抱歉噪音太大了。

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

https://wordpress.stackexchange.com/questions/48009

复制
相关文章

相似问题

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