Why aren’t some plugin styles loading when I load a template?

According to the WordPress Codex, using template_redirect to load a different template is discouraged and can cause certain code to not be executed, which of course can result in strange bugs. template_include is the more appropriate solution. It loads a template file but without the behavior mentioned above. add_action( ‘template_include’, function($original_template) { if (is_singular(‘business’)) { … Read more

Shortcode conflicts

When you define your shortcode, you might try one of a couple “if” statements to fix this issue, until you have time to create separate shortcodes. function cfgeo_shortcode( $atts, $content = “” ) { if (!isset($content) || stristr($content,’cfgeo’)!==FALSE){ // do short shortcode stuff here } else { // do ‘Container’ shortcode stuff here } return … Read more

Custom filter not working

I believe your the simple nature of your example may have led to a misunderstanding of the way appy_filters() would operate. There is a great article that really explains how to use add_filter() and apply_filters() well, using very readable examples. Basically, the problem appears to be that your code declares add_filter() AFTER you define it … Read more

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

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

How to display the category id along with category name on categories list?

You can add new column using below code. replace (your-texanomy) with your taxonomy slug. I have tested and its working fine. https://prnt.sc/qbibg0 #add header before category name function taxonomy_custom_column_header( $columns ){ $columns = array_slice($columns, 0, 1, true) + array(“cat_id” => “ID”) + array_slice($columns, 1, count($columns) – 1, true) ; return $columns; } add_filter( “manage_edit-(your-texanomy)_columns”, ‘taxonomy_custom_column_header’, … Read more