简体   繁体   English

WordPress:按日期升序更改标签的网址和顺序

[英]WordPress: change a tag's url and order by date in ascending manner

I have the following tag in my WordPress site: 我的WordPress网站中有以下标记:

http://www.example.com/tag/collection-100

and I want to change the tag's url to http://www.example.com/legends as well as make the posts displayed on that page to be ordered by date in ascending manner at the moment they are displayed in a descending way. 并且我想将标签的网址更改为http://www.example.com/legends ,并使该页面上显示的帖子在以降序显示的同时按日期升序排列。

I've searched for plugin which can do this but I couldn't find anything on WordPress' site. 我搜索了可以做到这一点的插件,但在WordPress网站上找不到任何插件。

I've also tried creating a new template and using the following code in it: 我也尝试过创建一个新模板,并在其中使用以下代码:

query_posts( 'tag=collection-100&order=ASC' );

which fetches the first 18 posts but the pagination doesn't work properly and instead it always shows the first 18 posts. 会获取前18个帖子,但分页无法正常工作,而是始终显示前18个帖子。

Any help much appreciated : ) 任何帮助,不胜感激:)

Create a custom template like this "example-template.php" and write your query like this: 创建一个类似“ example-template.php”的自定义模板,并编写如下查询:

get_header();

$loop = new WP_Query( array( 'post_type' => 'your-post-type',  'orderby' => 'date', 'order' => ASC ) ); 

while ( $loop->have_posts() ) : $loop->the_post(); 
    //print your needs
endwhile;

get_footer();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM