WP Query – Can’t get posts with specific taxonomy

It appears that you’re attempting to add a function to the init action hook from within the function you’re trying to add. Your code is doing this: function portalp_custom_taxonomies() { // … add_action( ‘init’, ‘portalp_custom_taxonomies’ ); // … } …when it needs to do this: function portalp_custom_taxonomies() { // … } add_action( ‘init’, ‘portalp_custom_taxonomies’ ); … Read more

Order custom post type by posts with most likes first

Yes, there is — use a meta_query with 2 clauses, one which selects posts having the meta, and the second clause with a ‘compare’ => ‘NOT EXISTS’ which selects posts without that meta. So in your $args array, just replace the ‘meta_key’ => ‘pld_like_count’ with this one: ‘meta_query’ => array( // make sure it’s OR … Read more