There are a lot of ways to add something to the <head>
section of a WordPress site. The easiest and probably the most clean way is using the functions.php
file of your theme. You can do that using the wp_head
action hook. Here’s how you can do it:
// Add something to the <head> section function add_something_to_head() { ?> <!-- Your HTML/Code here --> <meta name="description" content="Your description here"> <link rel="stylesheet" href="your-stylesheet.css"> <!-- End of your HTML/Code --> <?php } add_action('wp_head', 'add_something_to_head');
Replace the HTML/Code within the function with whatever you want to add to the <head>
section. This could be meta tags, links to stylesheets, scripts, etc.
Remember to replace "Your description here"
with the actual description you want to use and "your-stylesheet.css"
with the actual path to your stylesheet if you are adding a stylesheet.
Make sure to insert this code in your theme’s functions.php
file. It’s recommended to use a child theme or a custom plugin to add custom functionalities like this, to avoid losing changes during theme updates.