Forums

[resolved] Change listing order of custom post type (7 posts)

  1. Dave Redfern
    Member
    Posted 1 year ago #

    Hello all,

    I am using custom post types to create an event type. I have it all working great but is there a way to change the order they posts are listed in. So for example instead of the timestamp of the post it could be the event start date custom field?

    Many thanks in advance.

    Dave.

  2. Rev. Voodoo
    Volunteer Moderator
    Posted 1 year ago #

    how do you display the CPT?

    I'd assume with a query_posts?

    You can just add to the query with the orderby and order parameters....
    http://codex.wordpress.org/Function_Reference/query_posts#Orderby_Parameters

    query_posts( array(
    	// Set post type
    	'post_type' => 've_members',
    	'posts_per_page' => 50,
    	'orderby' => 'ID',
    	'order' => 'ASC',
    	// Enabled paging
    	'paged'=> ( get_query_var('paged') ? get_query_var('paged') : 1 ),
    ));

    heres an example of mine..... ve_members CPT, 50 per page, by post ID in reverse order

  3. Dave Redfern
    Member
    Posted 1 year ago #

    Hello. Thanks for your response.

    I didn't make it clear in my first post but I am referring to the admin.

    Dave.

  4. Rev. Voodoo
    Volunteer Moderator
    Posted 1 year ago #

  5. Dave Redfern
    Member
    Posted 1 year ago #

    thanks for that link. that seem great although as of 3.1 it appears to be built in so might be worth waiting to inherit the core functionality.

  6. Rev. Voodoo
    Volunteer Moderator
    Posted 1 year ago #

    lol, yup, if that's the case it would definitely make life easier eh?

  7. Dave Redfern
    Member
    Posted 1 year ago #

    Thanks for all your help. I'm gonna leave it to save the hassle when upgrading to 3.1.

Topic Closed

This topic has been closed to new replies.

About this Topic