【问题标题】:Wordpress the_excerpt() adding extra +-* at beginning of contentWordpress the_excerpt() 在内容开头添加额外的 +-*
【发布时间】:2015-05-23 13:15:08
【问题描述】:

在最新的帖子循环中,当我尝试回显 the_excerpt() 函数时,它会在摘录内容的分箱中添加 +-*。提前致谢。

    <?php if ( have_posts() ) : while (have_posts()) : the_post(); ?>
    <article class="media  group">
    <?php 
    // get the tag names of the current post.
    $posttags = get_the_tags($post->ID);
    foreach($posttags as $tag){

    ?>  
    <div class="meta meta--line">
    <h4 class="is-basefont is-inline is-forceful"><a href="#" class="is-category  "><?php echo $tag->name; ?></a></h4>
    <a href="<?php echo get_permalink($post->ID); ?>#disqus_thread" class="comment-count count-comments fa fa-comment" data-disqus-url="#">
    <?php echo $post->comment_count; ?>
    </a>
    </div>
    <?php  }  //end of get psot tags loop. ?>

    <?php  $url = wp_get_attachment_url( get_post_thumbnail_id( get_the_ID() ) ); ?>

    <div class="media__body">

    <h2 class="size_3"><a href="<?php the_permalink(); ?>" sl-processed="1"><?php the_title(); ?></a></h2>
    <div class="meta">
    <?php echo ' By <a href="#">'.$author_name = get_userdata($post->post_author)->display_name.'</a>';?>
    <?php echo ' On '. get_the_time('j, F Y g:i a ',$post->ID); ?></small>

    </div>
    <p><?php the_excerpt(); ?></p> 

    </div>
    </article>

    <?php endwhile; ?>

【问题讨论】:

  • 你需要显示一些代码...
  • 这是循环,当我在另一个地方使用它时它显示正常

标签: wordpress wordpress-theming


【解决方案1】:

在迁移客户的 WordPress 安装后,我们遇到了完全相同的问题。我们将其追溯到“添加此”插件: https://wordpress.org/plugins/addthis/

它需要帐户凭据。当插件在没有这些凭据的情况下激活时,它会输出这 3 个字符。停用插件,或添加帐户凭据以使 +-* 消失。

【讨论】:

    【解决方案2】:

    我找到了从 the_excerpt 函数中删除第一个空格字符的解决方案 n 取决于您要删除多少字符 $n=3;

     <?php echo substr(get_the_excerpt(), n,200); ?>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-07-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-01-21
      • 2021-12-17
      相关资源
      最近更新 更多