plugins – How to manipulate the content within wp_head

Question

I am looking to create a plugin which will allow me to update content within the wp_head function. I have the below code which is fine in allowing me to add new content during the wp_head load event;

<?php
function manipulate_head() {
    ?>
        <title>This is a second title</title>
    <?php
}

add_action('wp_head', 'manipulate_head');

However it does not allow me to remove or replace something that is already within the <head> tags on the page.

An example would be to update the <meta name="description"> tag in the section of the website. The website could have a <meta name="description"> in which case we need to update the content, otherwise we need to add a new one.

0
Kieran Headley 2 months 2022-06-06T23:55:12-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse