get_posts query matches too many results

Well, you need to include the type comparison, or alphanumeric comparison is applied here. In this case, you should add ‘type’ => ‘numeric’. Using Your Class Function <?php public function list_related_docs($id){ $docs_args = array( ‘post_type’ => ‘publication’, ‘post_status’ => ‘publish’, ‘posts_per_page’=> -1, ‘orderby’ => ‘meta_value_num title’, ‘order’ => ‘ASC’, ‘meta_key’ => ‘fund_list_order’, ‘limit’ => 4, … Read more

Query by key or author

You don’t really need to use the &new WP_Query just new WP_Query. The following code will resolve your problem. add_filter( ‘posts_search’, ‘q166788_search_modify’, 10, 2 ); function q166788_search_modify( $sql, $query ){ // Only if our variable is true we do the black magic if ( ! isset( $query->query_vars[‘search_conditional_toggle’] ) || $query->query_vars[‘search_conditional_toggle’] !== true ){ return $sql; … Read more

Avoid duplicate while merging two query post

Before I start, you have a problem with your meta_query. You should not use relation for a single inner meta_query array relation (string) – The logical relationship between each inner meta_query array when there is more than one. Possible values are ‘AND’, ‘OR’. Do not use with a single inner meta_query array. Your first query … Read more

Multiple meta query from array

$search_term is already an array of an array. When you eventually add that to your meta_query, you get an array of an array of an array, which will not work You are using AND as your relation operator which is the default for a multi-array meta_query. I would suggest that you drop that, and then … Read more

Get posts with no tags?

I’m not in the position to code right now, but here is an idea A thousand posts is quite a lot, but it is even more if you are retrieving all posts from the db in one go. What if you have ten thousand posts, of which only ten or twenty is not tagged after … Read more

How do I add an item to the WP admin menu?

You could do it with something like this in theme functions.php (at end) add_action(‘admin_menu’, ‘news_admin_test’); function news_admin_test() { add_menu_page( ‘News Page Title’, ‘News Option’, ‘manage_options’, ‘newspage’, ‘show_menu_news’, get_home_url() .’/wp-content/themes/my_theme/assets/img/logo.png’ ); } function show_menu_news () { echo ‘News content’; }