在帖子顶部显示摘录


Show excerpt at top of post

我有一个js测试模板,用于多个测试,我希望每个测试都能显示文章的摘录。我尝试在模板顶部添加<?php the_excerpt(); ?>,但这只显示了带有"点击阅读更多"按钮的摘录。有没有一种方法可以在不"阅读更多"的情况下,将摘录称为帖子,并在其后面添加内容?

http://www.lawlessfrench.com/expressions/quiz/

<?php
/*
Single Post Template: Quiz
*/
get_header(); 
?>
<div class="row">
<div class="col-md-8 content-area" role="main">
<h1><?php the_title();?></h1>
<h2>French Quiz</h2>
<?php the_excerpt(); ?>
<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
<?php endwhile; ?> 
<script type = "text/javascript" src = "<?php echo get_template_directory_uri(); ?>/js/<?php echo get_the_content(); ?>"></script>
<div id="quiz">
<form id="quiz-form">
</form>
</div>
</div>
<?php get_sidebar(); ?>
</div>
<?php get_footer(); ?>

尝试使用get_the_excerpt()

$my_excerpt = get_the_excerpt();
echo $my_excerpt;

有关此的更多信息,请访问http://codex.wordpress.org/Function_Reference/get_the_excerpt

编辑:

这和所有post函数一样,需要在循环中调用:

<?php
global $more; $more = -1; // suppress the more tag
if ( have_posts() ) {
    while ( have_posts() ) {
        $my_excerpt = get_the_excerpt();
        echo $my_excerpt;
    } // end while
} // end if
?>