0

当我添加

<?php $excerpt = get_the_excerpt() ?>

到下面的单页 php 代码,我得到“解析错误:语法错误,第 10 行上的意外 T_STRING”

<?php get_header(); ?>

<div class="post"><?php if (have_posts()) : while (have_posts()) : the_post(); ?>

    <div <?php post_class('margin') ?> id="post-<?php the_ID(); ?>">

<div class="casestudy"><a class="anchor-hover">
<?php echo get_the_post_thumbnail( $post->ID ); ?>
    <span class="details">
        <p class="desc"><?php $excerpt = get_the_excerpt() ?>
</p>
</span>
</a>
<?php the_content(); ?>
        </div>

<?php endwhile; endif; ?>
</div>
<?php get_footer(); ?>

我的functions.php文件原本没有

add_filter( 'get_the_excerpt', 'wp_trim_excerpt');

所以我补充说,但我仍然得到错误。我在这里想念什么?我把它从循环中取出了吗?

4

2 回答 2

3

我相信你忘记了;最后的那个。

我也很好奇为什么你只是简单地将变量设置在 a<p>而不是echoing 它?

于 2013-08-27T02:16:58.017 回答
1

你需要一个分号:) 简单的错误是最糟糕的,对吧?

于 2013-08-27T02:18:02.960 回答