Modifying wp_head
-
Hi there,
I am trying to modify (not add) HTML content within the <HEAD></HEAD> tags.
Therefore, I have created a wp_head filter within the functions.php file. However, I can’t seem to get it to work correctly. Can anyone help?
Step 1:
——-
Here is my function in the functions.php file:function mitulsdotcom_htmlCommentsStripper($content) {
$find=”/\<![ \r\n\t]*(–([^\-]|[\r\n]|-[^\-])*–[ \r\n\t]*)\>/”;
$replace=””;
return $value=preg_replace($find,$replace,trim($content));}
^ The above function takes in the content and strips of any HTML comments
Step 2:
——-Here is my filter in the functions.php file:
add_filter(‘wp_head’, ‘mitulsdotcom_htmlCommentsStripper’);
Any help is greatly appreciated.
Kind regards,
Mitul
- The topic ‘Modifying wp_head’ is closed to new replies.