Home › Forums › Winning Agent Pro Theme › Community Page/Archive Sort Order
Tagged: community CPT, sort order, wp-query
- This topic has 1 reply, 2 voices, and was last updated 7 years, 7 months ago by
Ginger Coolidge.
- AuthorPosts
- November 11, 2014 at 3:02 pm #3907
Winning Agent Staff
KeymasterIf anyone needs to control the order of items appearing on the Community page (default is descending by post id => Last published, Shown first) there is a plugin called Simple Custom Post Order.
You can choose what the plugin targets (I did community post types only). Then go to the Community Section in WordPress back end and drag and drop into order you would like.
Just curious if there is a way to do this in code verses using a plugin?
- November 13, 2014 at 4:19 pm #3935
Ginger Coolidge
ParticipantHi there,
Yes, you can do this. You’ll be adding whats called an action to your functions.php file. This article by Bill Erickson gives a few examples on how to change it.
I haven’t actually done one so I don’t have code to share, but you’ll be targeting the wap-community post_type and changing the ORDER BY portion of the query.
Also this page from the codex talks about WP_Query sort options:
http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_ParametersAnother useful plugin is called Query Monitor where you can see exactly what queries are called when you access the Community archive page (or any other page).
Here is the link for that plugin:
And finally, you can always check out the code in the Simple Custom Post Order plugin — it might help you with the syntax on how to construct your query. Reverse engineering is a great way to learn all this stuff!
Regards,
Ginger
- AuthorPosts
- You must be logged in to reply to this topic.