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


How to show all permalinks of wordpress?

我想在一个页面中显示我的wordpress帖子的所有当前永久链接。我不想使用档案。我使用数据库来执行此操作,但它仅显示 guid 链接。

意味着我想像这样列出:

http://www. 我的网站.com/类别/帖子1 http://www。我的网站。com/category/post1 http://www。我的网站。com/category/post1

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

http://www. 我的网站.com/?p=1 http://www。我的网站。com/?p=2 http://www。我的网站。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%/"的自定义结构,不带引号。

然后做这样的事情

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

其中 268 是您的帖子 ID

使用循环获取帖子 ID。http://codex.wordpress.org/Template_Tags/get_posts

如果您最近移动了应用程序,请确保已打开并选中永久链接设置选项卡一次。