duanfangfei5558 2017-01-04 08:00
浏览 21
已采纳

引入Wordpress帖子标题作为链接

I have a Wordpress site and I'm using the basic loop to bring in each Wordpress post

html

<?php 
 if ( have_posts() ) {
     while ( have_posts() ) {
     the_post(); 
     //
     // Post Content here
     //
    } // end while
  } // end if
?>

However I only want to bring in the title of each post as a link to that post (on its own single.php page) instead of all the content/images, etc. I have only been able to get all or nothing results.

  • 写回答

2条回答 默认 最新

  • doujiang3997 2017-01-04 08:06
    关注

    By keeping your code, you can go this way.

    <?php 
     if ( have_posts() ) {
         while ( have_posts() ) {
         the_post(); 
         //
         echo '<h2><a href="'.get_the_permalink().'">'.get_the_title().'</a></h2>';
         //
        } // end while
      } // end if
    ?>
    

    This way you'll get only your title with permalink. let me know if it helps you out or any thing else needed ?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用