Add a Span Around a Product Title in WooCommerce [closed]

Here is how you do it, First remove woocommerce single title action, and create your own function to handle the title, later add back the action using your newly created function. <?php remove_action(‘woocommerce_single_product_summary’,’woocommerce_template_single_title’,5); add_action(‘woocommerce_single_product_summary’, ‘woocommerce_my_single_title’,5); if ( ! function_exists( ‘woocommerce_my_single_title’ ) ) { function woocommerce_my_single_title() { ?> <h1 itemprop=”name” class=”product_title entry-title”><span><?php the_title(); ?></span></h1> <?php } … Read more

Add filter to wp_dropdown_pages() or wp_dropdown_categories() – no select container?

A filter called wp_dropdown_pages exists in the wp_dropdown_pages() function. That filter allows you to modify the output of the function. However, for the thing you want to do I would not recommend using this filter since this will apply to all code that calls wp_dropdown_pages(), including plugins. So, one way to approach your situation may … Read more

filter title from shortcode

why not to use the_title filter? add_filter(‘the_title’, ‘the_title_filter’); function the_title_filter($title){ $post = get_post(get_the_id()); //enter code here return $title; } as for shortcode – its imposible. in logical way – imposible.

changing variable through filters or action hooks

It won’t work the way you are doing it, but you are close. The reason you have to use a global is that you aren’t setting your $meta variable with the information returned from the filter. This: do_action(‘alter_loop’,$meta); Should be this: $meta = apply_filters(‘alter_loop’,$meta); Note: “Actions” do not return values. “Actions” do things. “Filters” accept … Read more

How apply_filters work in WordPress?

Yes the apply_filters() hook is bit confusing at first when you encounter it. I’ll try my best to explain this: first you need to know that filter hooks allow you to change data before displaying or storing data. Lets take an example function list_array(){ $arr_name = [‘val1’, ‘val2’, ‘val3’]; return $arr_name; } as you can … Read more

Remove classes from post_class()

One way would be to use preg_match and remove classes that matches given patterns, but… Since we know $post_id, we can use your code with a tiny modification: function lsmwp_remove_postclasses($classes, $class, $post_id) { $classes = array_diff( $classes, array( ‘hentry’, ‘post-‘ . $post_id, ‘type-‘ . get_post_type($post_id), ‘status-‘ . get_post_status($post_id), ) ); return $classes; } add_filter(‘post_class’, ‘lsmwp_remove_postclasses’, … Read more

Filter keywords from search query

If I understand you correctly you’re not looking for the wp_search_stopwords filter type of solution. So here’s a modification of the great answer by @kaiser that you referred to: /** * Exclude array of words from all search queries in the front-end * * Modification of http://wordpress.stackexchange.com/a/41100/26350 by @kaiser */ add_filter( ‘posts_search’, function( $search, $q … Read more