how to load the comment template from a plugin

You can use the comments_template filter to alter which file your CPT will use for comments. function wpse_plugin_comment_template( $comment_template ) { global $post; if ( !( is_singular() && ( have_comments() || ‘open’ == $post->comment_status ) ) ) { // leave the standard comments template for standard post types return; } if($post->post_type == ‘business’){ // assuming … Read more

Filter Hook for post table (not columns)

The same way you would do it on the frontend, with pre_get_posts. Combine it with get_current_screen() so you can tell which area of the admin you’re in, and hook the filter on admin_init so it doesn’t impact the frontend. There’s also the restrict_manage_posts which will let you add inputs to the filter column: https://developer.wordpress.org/reference/hooks/restrict_manage_posts/ Just … Read more

Set _regular_price 0 if empty in woocommerce product

The following will always set the price to default to 0 when creating/updating a product function wpa104760_default_price( $post_id, $post ) { if ( isset( $_POST[‘_regular_price’] ) && trim( $_POST[‘_regular_price’] ) == ” ) { update_post_meta( $post_id, ‘_regular_price’, ‘0’ ); } } add_action( ‘woocommerce_process_product_meta’, ‘wpa104760_default_price’ ); Again from the answer above you and the answer to … Read more

Custom Meta Box returns no HTML

Try adding array( $this, ‘myskills_html’ ) to the third argument. public function skillsmetabox_init() { add_meta_box( ‘myskills_meta’, ‘Proficiency’, array( $this, ‘myskills_html’ ) ); } Since this is class method, it should have the $this as well. The same way you did with add_action( ‘save_post’, array( $this, ‘save_metabox_details’ ) );

Loop in elementor custom widget not working

I would recommend switching to a standard post loop: $args = [ ‘posts_per_page’ => 12, ‘category_name’ => ‘featured’, ‘orderby’ => ‘post_date’, ‘order’ => ‘ASC’, ]; $query = new \WP_Query($args); if ( $query->have_posts() ) { while ( $query->have_posts() ) { $query->the_post(); ….. } \wp_reset_postdata(); } Note that I: switched to modern PHP array syntax of [] … Read more