duanjing3656 2015-10-20 03:44
浏览 28
已采纳

Hep需要WordPress目录主题

I am using this Directory theme:

http://themeforest.net/item/directory-multipurpose-wordpress-theme/full_screen_preview/10480929

Just go to the first preview. So that you can see the categories below the map. I have set that in a different style but it is showing me alphabetically. Here is the code used for that:

                        'posts_per_page'            => "-1",
                        'post_type'                 => 'directory_types',
                        'post_status'               => 'publish',
                        'orderby'                   => 'ID',
                        'order'                     => 'ASC',

Can you please help me how to adjust the code so that they are not arranged in alphabetical order and by the order I wanted?

Here is the link for reference:

test.techkalph.com

Note: No post/category reorder plugin is working there. Need to adjust the code.

  • 写回答

1条回答 默认 最新

  • dsfdsf21321 2015-10-20 06:11
    关注

    I'm assuming this is part of a get_posts() call. There are at least three ways to do this, depending on how much functionality you have with the properties of the directory types.

    Option 1. If you can set the "order" of the directory type (it will be an option somewhere when you edit the directory type), then you can make them list in that order by changing the following:

    'orderby'     => 'menu_order',
    

    Option 2. If you don't have the ability to set the order, it gets a little more cumbersome. You will first need to get the post IDs of the directory types (when you edit them, it will probably say something like "post=13" in the URL). You can then set the order by changing the following:

    'orderby'     => 'post__in',
    'include'     => '43,12,21,45',
    

    Where the numbers after 'include' is the order that you want. Note that this requires you to list all the directory type ids that you want listed.

    Option 3 If you can't do either of the above, you can order them by date by setting the following:

    'orderby'    => 'date',
    'order'      => 'ASC',
    

    If they are in the reverse order of what you were thinking, try 'order' => 'DESC' instead.

    If you can change the publish date of the posts, this will work.

    Also, see Template Tags/get posts. There may be something more tricky that I'm not thinking of.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 怎么把多于硬盘空间放到根目录下
  • ¥15 Matlab问题解答有两个问题
  • ¥50 Oracle Kubernetes服务器集群主节点无法访问,工作节点可以访问
  • ¥15 LCD12864中文显示
  • ¥15 在使用CH341SER.EXE时不小心把所有驱动文件删除了怎么解决
  • ¥15 gsoap生成onvif框架
  • ¥15 有关sql server business intellige安装,包括SSDT、SSMS。
  • ¥15 stm32的can接口不能收发数据
  • ¥15 目标检测算法移植到arm开发板
  • ¥15 利用JD51设计温度报警系统