Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何显示wordpress的所有永久链接?_Php_Wordpress_Permalinks - Fatal编程技术网

Php 如何显示wordpress的所有永久链接?

Php 如何显示wordpress的所有永久链接?,php,wordpress,permalinks,Php,Wordpress,Permalinks,我想在一页中显示我的wordpress帖子的所有当前永久链接。我不想使用档案。我使用数据库来实现这一点,但它只显示guid链接 意思是我想列这样的清单: 。我的网站。com/category/post1 . 我的网站。com/category/post1 . 我的网站。com/category/post1 但我从数据库中得到的是: 。我的网站。com/?p=1 . 我的网站。com/?p=2 . 我的网站。com/?p=3 请帮帮我试试这个 <?php $args = array('p

我想在一页中显示我的wordpress帖子的所有当前永久链接。我不想使用档案。我使用数据库来实现这一点,但它只显示guid链接

意思是我想列这样的清单:

。我的网站。com/category/post1 . 我的网站。com/category/post1 . 我的网站。com/category/post1

但我从数据库中得到的是:

。我的网站。com/?p=1 . 我的网站。com/?p=2 . 我的网站。com/?p=3

请帮帮我试试这个

<?php 
 $args = array('post_type' => 'post', 'posts_per_page' => -1 ); 
 $loop = new WP_Query($args); 
 if( $loop->have_posts() ): 
     while( $loop->have_posts() ): 
         $loop->the_post(); 
         global $post; 
         echo get_permalink($post->ID);
     endwhile; 
 endif; 
 wp_reset_query();
?>

将永久链接设置设置为postname first


玩得开心:)

您需要使用“/%postname%/”将永久链接设置为自定义结构,不带引号

然后像这样做

<a href="<?php echo get_permalink( 268 ); ?>">My link to a post or page</a>

其中268是您的邮政id

使用循环获取post ID。


如果您最近移动了应用程序,请确保打开并检查了一次permalinks设置选项卡。

转到
admin/settings/permalink
,setI已经这样做了。现在我想在不同的页面上显示所有这些参数。我只想列出我网站的当前URL有一个插件,叫做WP Sitemap PageThat's great!您能告诉我如何将这些URL存储到数据库中吗?@rameshardhi您不需要将其再次存储到数据库中。它们已经存储在数据库中。为什么要复制?它们在数据库中的位置?我在数据库中只找到guid URL,但我想保存这些当前的参数。我只是想这样做…你不需要使用SQL查询来获取永久链接。有不同的方法可以使用WP核心函数来实现这一点。只需使用上面的代码来检索它。为什么需要再次存储它?永久链接由WP core处理。你不必担心