Need to add onclick javascript at backend of my wordpress site

There are many different contact form plugins. Some of them will store the submitted forms in the WordPress backend. This makes it easy to track the number of submitted forms. An example of a plugin that stores the responses is Happy Forms. Of course there are many others. I hope this addresses your request.

wp_query comment and meta query

The inline documentation of WP_Query has this: Filter results by comment count. Provide an integer to match comment count exactly. Provide an array with integer ‘value’ and ‘compare’ operator (‘=’, ‘!=’, ‘>’, ‘>=’, ‘<‘, ‘<=’ ) to compare against comment_count in a specific way. So there should only be one array, not 2 like with … Read more

change the default order of posts only for specific categories

Problem 1 $foo = is_category( … ); Is the same as: global $wp_query; // the main query $foo = $wp_query->is_category(….); So when filtering the query, don’t check the main query, check the query you’re filtering instead: $query->is_main_query() && $query->is_category( …. Problem 2 Look at this: array(‘573,1060,1061,1062,1063,1065,1066,1064’) You might think this is a list of 8 … Read more

Update query for wp_posts and wp_postmeta

The post_id column in the wp_postmeta table is a reference to the ID column in the wp_posts table. I’d suggest using the native update_post_meta() function in WordPress to update the meta data. E.g. (Post ID is 123 in this example, and we’re updating the price to 100.00): update_post_meta(123, ‘_price’, ‘100.00’); Here is the SQL equivalent: … Read more

Sort by presence of thumbnail

Easy peasy! $args_for_query1 = [ ‘post_type’ => ‘custom_project’, ‘post_status’ => ‘publish’, ‘meta_query’ => array( array( ‘key’ => ‘_thumbnail_id’ ) ) ]; $args_for_query2 = [ ‘post_type’ => ‘custom_project’, ‘post_status’ => ‘publish’, ‘meta_key’ => ‘_thumbnail_id’, ‘meta_compare’ => ‘NOT EXISTS’, ]; $query1 = new WP_Query($args_for_query1); $query2 = new WP_Query($args_for_query2); $wp_query = new WP_Query(); $wp_query->posts = array_merge( $query1->posts, $query2->posts … Read more