我试着在我的摘录周围放一个链接,就像在我的标题上一样,但我在这一行得到了一个解析错误:
echo '<div class="excerpt">''<a href="' the_permalink(); '">' . nectar_excerpt($excerpt_length) . '</a></div>';?>下面是我的post-element的全部代码:
<div class="post-header">
<h3 class="title">
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
</h3>
<span class="meta-author"><?php the_author_posts_link(); ?> </span>
<span class="meta-category"> | <?php the_category(', '); ?> </span>
<span class="meta-comment-count"> | <a href="<?php comments_link(); ?>">
<?php comments_number( esc_html__( 'No Comments','salient'), esc_html__( 'One Comment','salient'), '% '. esc_html__( 'Comments','salient') ); ?></a>
</span>
</div>
<?php
$excerpt_length = ( !empty( $nectar_options['blog_excerpt_length'] ) ) ?
intval( $nectar_options['blog_excerpt_length'] ) : 30;
echo '<div class="excerpt">''<a href="' the_permalink(); '">' . nectar_excerpt($excerpt_length) . '</a></div>';?>
<div class="meta-tags"> <?php the_tags(''); ?> </div>
<div class="tags-divider"></div>发布于 2019-10-10 06:58:07
在PHP中,文本字符串使用点字符合并。因此,如果你想把它们连接在一起,你应该这样做:
$a = "text1";
$b = "text2";
echo ($a . $b); // prints "text1text2"或者在你的例子中是这样的:
echo "text1" . function() . "text3"; // prints text1text2text3如果你使用像string这样的函数,你不要在最后使用";“字符,因为它会结束整行代码。
echo "text1" . "text2"; . "text3"; // wrong
echo "text1" . "text2" . "text3"; // correct
echo "text1" . function(); . "text3"; // wrong
echo "text1" . function() . "text3"; // correct因此,只需添加点并删除分号,它就会起作用。
echo '<div class="excerpt">' . '<a href="' . the_permalink() . '">' . nectar_excerpt($excerpt_length) . '</a></div>';?>发布于 2019-10-10 05:35:30
试一试?
echo '<div class="excerpt"><a href="' . the_permalink() . '">' . nectar_excerpt($excerpt_length) . '</a></div>';https://stackoverflow.com/questions/58310602
复制相似问题