如何在wordpress中获取搜索结果的页面链接


how to get page link of searched result in wordpress?

我在阅读更多按钮中尝试了这段代码,我想要页面的链接

<div class="blogleft">
  <ul class="eachblog">
  <?php while ( have_posts() ) : the_post(); ?>
  <li>
      <h1>
        <?php the_title();?>
      </h1>
      <div class="perpostbg">
       <?php $content = get_the_content(); echo substr($content,0,400); echo '...';?>
        <a href="#" class="readmorebutton">Read more</a>
      </div>
    </li>
   <?php endwhile;?>
 </ul>
 </div>

使用永久链接

<a href="<?php echo get_permalink(); ?>" class="readmorebutton">Read more</a>

<a href="<?php echo the_permalink(); ?>" class="readmorebutton">Read more</a>

只写

<a href="<?php the_permalink(); ?>" class="readmore">Read more</a>

这个代码在您的搜索循环