如何在WordPress中按字母顺序对类别帖子进行排序?

抱歉, 但是我无法弄清楚我的代码出了什么问题。

我正在尝试按字母顺序对类别3中的帖子进行排序, 但我认为我做错了。

<?php
    $catquery = new WP_Query( 'cat=3' );
    while($catquery->have_posts()) : $catquery->the_post('&orderby=title&order=ASC');
?>

#1


尝试这个:

<?php

$args = array(
    'posts_per_page' => -1, 'cat' => 3
    'orderby' => 'title', 'order' => 'DESC'
);

    $catquery = new WP_Query($args);
    while($catquery->have_posts()) : $catquery->the_post();
?>

希望对你有帮助。


#2


尝试从查询本身进行排序

$args = [
            'order' => 'ASC', 'orderby' => 'title', ];

        $query = new WP_Query($args);

来源:

https://www.srcmini02.com/63504.html

微信公众号
手机浏览(小程序)

Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_37612.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?