How do I display an article using a WordPress custom field?

Yes, and you can use the meta_key along with meta_value parameter. Secondly, you’re going to need two queries when there are no featured posts: Query the featured articles/posts: $q = new WP_Query( [ ‘post_type’ => ‘post’, ‘meta_key’ => ‘featured’, ‘meta_value’ => ‘1’, ‘posts_per_page’ => 3, ‘no_found_rows’ => true, ] ); Query random posts: $q = … Read more

How to get meta key list efficiently?

As mentioned in the comments you can query the postmeta table directly: public function get_metadata_keys(){ global $wpdb; $meta_query = $wpdb->get_results( ” SELECT DISTINCT meta_key FROM {$wpdb->postmeta} ” , ARRAY_A ); $meta_keys = wp_list_pluck( $meta_query, ‘meta_key’ ); return $meta_keys; } This will return the list of all meta_keys associated to any post.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)