Wrap h1-h6 in a div

Try this code function wrap_heading_with_div( $content ) { $heading = ‘/<h\d.*?>(.*?)<\/h\d>/ims’; $wrapper=”<div class=”title”>$0</div>”; $content = preg_replace($heading, $wrapper, $content); return $content; } add_filter( ‘the_content’, ‘wrap_heading_with_div’ ); Live Demo

Using ‘posts_where’ on a query with a custom field

you don’t need to use posts_where for this kind of query , you can just use “meta_query“ $today = date(“Ymd”); $args = array( ‘meta_query’ => array( array( ‘key’ => ‘TheDate’, ‘value’ => $today, ‘compare’ => ‘>=’ ) ), ‘cat’ => ‘4’, ‘posts_per_page’ => -1, ‘orderby’ => ‘meta_value_num’, ‘meta_key’ => ‘TheDate’, ‘order’ => ‘ASC’ ); $the_query … Read more

How to filter a wordpress core function?

This worked for me: function uploader_text() { ?> <p class=”upload-html-bypass hide-if-no-js”> <?php _e(‘mytext here’); ?> </p> <?php } remove_action(‘post-html-upload-ui’, ‘media_upload_html_bypass’); add_action(‘post-html-upload-ui’, ‘uploader_text’); You tried to do “remove_action” after the action already happened. That was the bug.

Apply the_content filter, but prevent other hooked actions

If this is only for certain content areas, create your own filter, and base it off the original the_content filter. Put this in your functions.php (found in wp-includes/default-filters.php) add_filter( ‘se152488_the_content’, ‘wptexturize’ ); add_filter( ‘se152488_the_content’, ‘convert_smilies’ ); add_filter( ‘se152488_the_content’, ‘convert_chars’ ); add_filter( ‘se152488_the_content’, ‘wpautop’ ); add_filter( ‘se152488_the_content’, ‘shortcode_unautop’ ); add_filter( ‘se152488_the_content’, ‘prepend_attachment’ ); Then use the … Read more

How can filters be run when they are never applied?

WordPress creates automatically filters for each theme_mod with this format theme_mod_{name}. The filters are called in get_theme_mod(). In your case, nav_menu_locations is the theme_mod and this filter is created by WordPress: //$value of the mod is passed to filter callbacks apply_filters(‘theme_mod_nav_menu_locations’, $value); For reference: get_theme_mod docuemntation (see the Notes section). theme_mod_{name} documentation Line 921 of … Read more

Is there a wildcard/catchall filter hook?

I’ve tried the same thing and was able to hook into the pre_option_ filter by using all as filter. add_filter(‘all’, ‘pre_option_’,1,3); function pre_option_($actionHook,$bool=false,$option_name) { if(strpos($actionHook,’pre_option_’) === FALSE){ return $bool; } }

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)