Custom field totals

Get all of the post ids from the specific post type, loop through them and simply add the custom fields together and display the sum below the post type title on edit.php (Notice the add_filter first parameter, you need to change the products part to your post type name) add_filter(‘views_edit-products’,’products_price_sum’); function products_price_sum($views) { $args = … Read more

Setting a custom $query->query_vars[‘meta_key’] breaks the WordPress menu

I was having the exact same problem on an archive page of a custom post type with a needless extra query; for pagination reasons. Searching for the same solution I found this post on Stack Overflow https://stackoverflow.com/questions/21303743/new-wp-query-or-pre-get-posts-to-view-all-posts-for-custom-post-type I had a play and added this line of code into the function. if( ! $query->is_post_type_archive()) return; So … Read more