How can I append this php link to the end of the e

2019-09-20 05:30发布

问题:

How can I append <a class="see_more" href="<?php the_permalink();?>">SEE MORE >></a> part to the end of the excerpt?

 <div class="item_content">
   <h4><a href="<?php the_permalink();?>"><?php the_title();?></a></h4>
  <?php 
      add_filter('excerpt_length', 'df_new_excerpt_length_30');
      the_excerpt();
      remove_filter('excerpt_length', 'df_new_excerpt_length_30'); 
  ?>
  <a class="see_more" href="<?php the_permalink();?>">SEE MORE >></a>
 </div>

回答1:

OK found it. First open your functions.php file, and paste the following code inside the php tags:

// Changing excerpt more
   function new_excerpt_more($more) {
   global $post;
   return '… <a href="'. get_permalink($post->ID) . '">' . 'Read More &raquo;' . '</a>';
   }
   add_filter('excerpt_more', 'new_excerpt_more');

remove the <a class="see_more" href="<?php the_permalink();?>">SEE MORE >></a> entirely.