Wednesday, 14 December 2016

Filtering Data with WP_Meta_Query – GenerateWP


WordPress allows us to filter data by custom fields. The WP_Meta_Query class is used to generate SQL WHERE clauses to filter queries by meta fields. Now after we announced our WP_Date_Query Generator, the next natural move was to let you easily create advanced meta queries using our new WP_Meta_Query Generator. Filtering by Custom Fields
WordPress allows you to filter posts based on post parameters like publish date, author, status, type, ect. Filter posts based on all kinds of taxonomies And filter posts based on other default values. But that is not always enough and you might need some extra data which is your own data – your own custom meta fields.
Custom fields are additional data fragments added to the main post, they are saved in a separate table – wp_postmeta. This is also applies to comments, users and terms each of them with as a separate meta own table.
When retrieving posts / users / comments filtered by meta data it has a performance toll as you use SQL JOIN. But in most cases the benefits outweigh the disadvantages. To reduce performance impact, you should not use the your own SQL statements but use WP_Meta_Query class which implements internal cache.
Retrieving
Source: https://managewp.org/articles/14026/filtering-data-with-wp-meta-query-generatewp




source https://williechiu40.wordpress.com/2016/12/14/filtering-data-with-wp_meta_query-generatewp/

No comments:

Post a Comment