How do I override the search template in a plugin?

You can use template_include filter hook add_filter(‘template_include’,’my_custom_search_template’); function my_custom_search_template($template){ global $wp_query; if (!$wp_query->is_search) return $template; return dirname( __FILE__ ) . ‘/my_search_template.php’; } /*UPDATE: there was a missing “;” after $template*/

Hooking into the post editing screen for an existing page only

You should really only need to run this on an existing post, since new posts will be created in the manner you specify. add_action( ‘load-post.php’, ‘custom_content_conversion’ ); function custom_content_conversion() { if (! empty($_GET[‘post’]) ) { // Get the post object $post = get_post($_GET[‘post’]); // If the post object has content, store it in the meta … Read more

How to hide category name

First of all, I wouldn’t recommend to use categories to show posts anywhere. Such approach has many consequences (it creates category archive, feeds, and so on). But if you already have such solution, then you can use get_the_categories filter and remove given category from the list. add_filter( ‘get_the_categories’, function ( $categories, $id ) { foreach … Read more

What is the difference between add_action and add_filter [duplicate]

add_action add_action is what you use to create a trigger “hook” – when something happens, do-something-else. add_Filter add_filter is used to “hook” data change/replace – where there is [some-code], change it to some-other-expanded-code. add_filter ( string $tag, callable $function_to_add, int $priority = 10, int $accepted_args = 1 ) Hook a function or method to a … Read more

How to Update the Order-Items While Editing an Order on the WooCommerce Admin Order Screen [closed]

The woocommerce_order_before_calculate_totals hook executes in the Edit Order admin screen when an item is changed or the ‘recalculate’ button is pressed. This allows you to loop through each item and fee in the order and edit as required. I have a fee called ‘Deposit’ which I update if it exists or I add if it … Read more