Php 引入Wordpress文章标题作为链接

Php 引入Wordpress文章标题作为链接,php,wordpress,Php,Wordpress,我有一个Wordpress网站,我正在使用基本循环来引入每个Wordpress帖子 html 但是,我只想将每篇文章的标题作为该文章的链接(在其单独的.php页面上),而不是所有内容/图像等。我只能得到全部或全部结果。保留代码,您就可以这样做 <?php if ( have_posts() ) { while ( have_posts() ) { the_post(); // echo '<h2><a href="'.ge

我有一个Wordpress网站,我正在使用基本循环来引入每个Wordpress帖子

html



但是,我只想将每篇文章的标题作为该文章的链接(在其单独的.php页面上),而不是所有内容/图像等。我只能得到全部或全部结果。

保留代码,您就可以这样做

<?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
?>


这样,你将只获得你的标题与永久链接。如果它对您有帮助或有其他需要,请告诉我。

保留您的代码,您可以这样做

<?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
?>


这样,你将只获得你的标题与永久链接。让我知道它是否有助于您或其他需要的东西?

您好,您可以提供这样的东西

<?php 
 if ( have_posts() ) {
 while ( have_posts() ) {
 the_post(); 
 //
 echo '<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>';
 //
  } // end while
 } // end if
?>

有关更多详细信息,请访问此网站

嗨,你可以给我这样的礼物

<?php 
 if ( have_posts() ) {
 while ( have_posts() ) {
 the_post(); 
 //
 echo '<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>';
 //
  } // end while
 } // end if
?>

有关更多详细信息,请访问此网站

是否“在自己的single.php页面上”意味着每篇文章都有一个自定义模板?如果是,您在哪里设置该值?我的意思是,问题不仅仅是获取帖子的链接,而不是内容?或者这是您在这里面临的唯一问题吗?是否“在它自己的single.php页面上”意味着每个帖子都有一个自定义模板?如果是,您在哪里设置该值?我的意思是,问题不仅仅是获取帖子的链接,而不是内容?或者这是你在这里面临的唯一问题?