WordPress.org

Ready to get started?Download WordPress

Forums

Query Custom Post Type (3 posts)

  1. 14ner
    Member
    Posted 3 years ago #

    Hi Everyone,

    I am currently building a hall of fame site. I created a custom post type for the athletes. Then I created a custom page template called Athletes where I would like to display a list of all of the athletes.

    Here is my question:

    I would like to query links to the athletes into two columns. I have a custom meta box with the athletes name so I would also like to use that field to sort the athletes alphabetically. Also the number of athletes is always changing so some way the query would need to first count the number of post and then divide by two.

    Any help is appreciated.

    14ner

  2. westondeboer
    Member
    Posted 3 years ago #

    here is an example of a query of a page i am working on right now:
    $wp_query->query('&paged='.$paged&meta_key=fb_count&order=DESC&orderby=meta_value_num');

    The custom field is the meta_key, in my example above it is fb_count and it orders is DESC which is highest to lowest. You should change orderby=meta_value_num to orderby=meta_value

  3. 14ner
    Member
    Posted 3 years ago #

    Thanks for the help.

    The code above doesn't seem to be working though.

    -14ner

Topic Closed

This topic has been closed to new replies.

About this Topic