wp-papi / papi

:rocket: WordPress Page Type API with custom fields
https://wp-papi.github.io
MIT License
263 stars 32 forks source link

Intent of papi_get_page_type_key #224

Closed sasimon closed 7 years ago

sasimon commented 7 years ago

I have a question regarding papi_get_page_type_key(). Is its purpose simply to return the constant '_papi_page_type'? Is its purpose to be passed as the 'meta_key' parameter in a WP_Query object? If so, then I believe that it would benefit us all if the documentation contained a whole section on relationships between Papi slugs and WP post meta keys. It would force out themes and plugins to improve their performance by not having WP_Query return such large data sets (since filtering criteria would be more evident). But my immediate concern is filtering by the Papi page type used to create each post, as a substitute for post type filtering. Thank you!

frozzare commented 7 years ago

The purpose of papi_get_page_type_key() is to return the meta key that is used for the page type id and you can pass it as a meta key value to WP_Query.

I'm not sure that's more documentation is needed since the slugs you sets for the properties is the slugs that are used as meta keys in the database. Some properties saves the data in a more advanced set but it isn't so hard to just look in the database and how it saved, it's much easier than reading documentation. If you think documentation is the key you are welcome to contribute documentation, but don't have the time to write more documentation, it's hard to run a big project mostly on your own and you have to prioritize where to put your time.

You can create WP_Query that performance well but that is another problem. 10up has some good information about this https://10up.github.io/Engineering-Best-Practices/php/ and there is more sites out there with more information.