I am currently putting together a site for a client using the "Grand College" wordpress theme.
As part of the theme they offer a great table function which collates 'courses' into a table. Each 'course' is its own wordpress page with key details, entered when creating each course which are then used as the meta table.
See example of the table: http://www.heymrleej-test.com/wp2/education/cpd-events/
However, I am unable to present the courses in the way I want. I would like to have by default, the courses collated by date on this page. (ie the first column on left by date order - soonest first).
Does anyone have any idea how this could be done?
Rashad Aliyev answers:
You should use special query with orderby parametrs ( http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters )
Also you can use meta_key and meta_value in your query.
Rashad Aliyev comments:
Of course I need to see this functions for helping in this query. Please send this page template via email.
Rashad Aliyev comments:
I gave you link for making looking orderby parametrs;) Which area do you want you can use it for orderby.
Sort retrieved posts.
order (string) - Designates the ascending or descending order of the 'orderby' parameter. Defaults to 'DESC'.
'ASC' - ascending order from lowest to highest values (1, 2, 3; a, b, c).
'DESC' - descending order from highest to lowest values (3, 2, 1; c, b, a).
<strong>orderby (string) - Sort retrieved posts by parameter. Defaults to 'date'.</strong>
'none' - No order (available with Version 2.8).
'ID' - Order by post id. Note the captialization.
'author' - Order by author.
'title' - Order by title.
<strong>'date' - Order by date.</strong>
'modified' - Order by last modified date.
'parent' - Order by post/page parent id.
'rand' - Random order.
'comment_count' - Order by number of comments (available with Version 2.9).
'menu_order' - Order by Page Order. Used most often for Pages (Order field in the Edit Page Attributes box) and for Attachments (the integer fields in the Insert / Upload Media Gallery dialog), but could be used for any post type with distinct 'menu_order' values (they all default to 0).
<strong>'meta_value' - Note that a 'meta_key=keyname' must also be present in the query. Note also that the sorting will be alphabetical which is fine for strings (i.e. words), but can be unexpected for numbers (e.g. 1, 3, 34, 4, 56, 6, etc, rather than 1, 3, 4, 6, 34, 56 as you might naturally expect).</strong>
'meta_value_num' - Order by numeric meta value (available with Version 2.8). Also note that a 'meta_key=keyname' must also be present in the query. This value allows for numerical sorting as noted above in 'meta_value'.
Show Posts sorted by Title, Descending order
Lee Jackson comments:
email sent with login details.
Rashad Aliyev comments:
I've solved the problem what you want.
Lee Jackson comments:
Thanks Rashad. This is working perfectly now.
:)
AdamGold answers:
Can you post here the code of the file of the table?
I suppose there's query_posts in that file or maybe get_posts (or WP_Query), what you need to do is to add a parameter to sort it by date: 'orderby' => 'date', 'order' => 'DESC'
Lee Jackson comments:
I'm not sure which code refers to the table. I can offer access to the test site if you like?
Send me your email details and I'll forward the login details.
Lee Jackson comments:
I'm not sure which code refers to the table. I can offer access to the test site if you like?
Send me your email details and I'll forward the login details.
Jim Dugan answers:
There's a great jquery library:
http://datatables.net/
That lets the user order tables by clicking on headings.
I used it on the schedule table on
http://schoonermaryday.com/sailing-schedule/
Click on the headings to sort the table differently.
Ross Wilson answers:
If you haven't found anyone to help you out yet I can get on your server and make the change. Just send me an email at [email protected]
Sébastien | French WordpressDesigner answers:
send me your theme by email
[email protected]
i look at that immediately
Sébastien | French WordpressDesigner comments:
In this theme "course" is a custom post type.
So you must just change "orderby=ID" by "orderby=date" in the query_post