简体   繁体   中英

Hep needed with WordPress Directory theme

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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