Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/234.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在_摘录()中插入链接;标签_Php_Css_Wordpress - Fatal编程技术网

Php 在_摘录()中插入链接;标签

Php 在_摘录()中插入链接;标签,php,css,wordpress,Php,Css,Wordpress,我想删除段落和“阅读更多”之间的换行符。它应该在三个点之后继续。在该段内。希望你明白我的意思 是否可以将链接放在摘录中?你能用css修复它吗 谢谢 <?php $args = array( 'numberposts' => 3 ); $lastposts = get_posts( $args ); foreach($lastposts as $post) : setup_postdata($post); ?> <h2 class="news"><?php

我想删除段落和“阅读更多”之间的换行符。它应该在三个点之后继续。在该段内。希望你明白我的意思

是否可以将链接放在摘录中?你能用css修复它吗

谢谢

<?php
$args = array( 'numberposts' => 3 );
$lastposts = get_posts( $args );
foreach($lastposts as $post) : setup_postdata($post); 
?> 

<h2 class="news"><?php the_title(); ?></h2>


<?php the_excerpt(); ?>  //this returns the paragraph with three dots

<a href="<?php the_permalink(); ?>">Read more</a>  //this should somehow be inside the excerpt


<?php endforeach; ?>

//这将返回带有三个点的段落
//这应该在摘录中

没有,但修复很简单

foreach()之后添加此行:


现在它应该停止打印标签。

在style.css中,将p标签的边距更改为0px

p {
   margin: 0px;
  }

在样式表中添加以下行:

#news p {margin-bottom:0px;}
这将删除文本和“阅读更多”链接之间的空格。

根据,您可以这样做

将其放在主题的functions.php中,以使“阅读更多”链接指向 邮报

函数新建\u摘录\u更多($更多){
全球$员额;
返回“”;
}
添加过滤器(“摘录更多”、“新摘录更多”);

这会起作用,但会影响整个网站的布局。我建议有一个更具体的规则。没错@本的答案更好。你在现场编辑过吗?尝试清除缓存并在浏览器中加载style.css,刷新几次,直到看到其中的更改,然后访问该站点。是的,该解决方案完全删除了标记,使所有内容都集中在一行中。这个(或Ben的)解决方案,将Read More放在下一行,去掉中间的空格。我用过这个,但是如果帖子短了,那么你决定的值就不会有链接了。啊。。。您编辑的问题更清楚。这些解决方案将删除短文本后的空格,但不会将其添加为行的一部分。对于这一点,Blender的答案就是你想要的答案。
#news p {margin-bottom:0px;}
function new_excerpt_more($more) {
       global $post;
    return '<a href="'. get_permalink($post->ID) . '">Read the Rest...</a>';
}
add_filter('excerpt_more', 'new_excerpt_more');