Recall & Review
beginner
What is a custom post type in WordPress?
A custom post type is a content type you create to organize and display different kinds of content beyond the default posts and pages, like portfolios, products, or events.
Click to reveal answer
beginner
Which WordPress function is used to query custom post types?
The <code>WP_Query</code> class is used to query custom post types by setting the <code>post_type</code> parameter to the custom post type's name.Click to reveal answer
intermediate
How do you query multiple custom post types at once?
You pass an array of post type names to the
post_type parameter in WP_Query, like ['book', 'movie'].Click to reveal answer
intermediate
What parameter do you use to order custom post type query results by a custom field?
Use
meta_key to specify the custom field and orderby set to meta_value or meta_value_num in WP_Query.Click to reveal answer
advanced
Why should you use
pre_get_posts action when modifying main queries for custom post types?Because it lets you safely modify the main query before it runs, ensuring your custom post type content shows up correctly without breaking other queries.
Click to reveal answer
Which parameter in WP_Query specifies the custom post type to query?
✗ Incorrect
The
post_type parameter tells WP_Query which post type(s) to fetch.How do you query both 'book' and 'movie' custom post types together?
✗ Incorrect
You pass an array of post type names to
post_type to query multiple types.Which WP_Query parameter orders results by a custom field's numeric value?
✗ Incorrect
Use
orderby => 'meta_value_num' with meta_key to sort by numeric custom fields.What hook lets you modify the main query before it runs?
✗ Incorrect
The
pre_get_posts hook allows safe modification of the main query.If you want to show only published custom posts, which parameter do you set?
✗ Incorrect
Setting
post_status to publish fetches only published posts.Explain how to create a query for a custom post type called 'event' that orders results by a custom date field.
Think about how to tell WP_Query which post type and custom field to use for sorting.
You got /5 concepts.
Describe why and how you would use the pre_get_posts hook when working with custom post type queries.
Consider how to change what WordPress shows on archive or home pages.
You got /4 concepts.