1

I want to order my custom post type called sermons by sermon date, not the date entered.

See here: http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters

How do I know the meta_key of my custom post type? Is this the ID, or name?

0

2 Answers 2

0

What is "sermon date", is it the custom field? If so, your meta_key is the name of your custom field used for that date. If not, how are you getting the sermon date?

Might be something like this:

$args = array(
    'post_type' => 'sermons',
    'meta_key'  => 'sermon_date',
    'orderby'   => 'meta_value',
    'meta_type' => 'DATE'
);
$query = new WP_Query( $args );
0

Meta keys are arbitrary and not connected to Custom Post Type definition.

For any post custom meta fields can be created with any valid string key.

So basically discovery of the keys is completely up to documentation and/or reading source code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.