How to Add to the <head> section of my website?

Hello, I’ve been trying to change my website preview on Social nets like Facebook.

I’ve seen online that I should add meta property=“og:image” / meta property=“og:title” / meta property=“og:description” to the < head > section of my website.

Is it possible to do it even if I’m using the X-theme and the builder cornerstone? How do I do it?

thanks in advance.

Hey Giulia,

What you’re trying to add is called Open Graph and our themes does have a basic Open Graph integration. You can read about that at https://theme.co/apex/forum/t/customizer-social-options/141

If you wish to use your own Open Graph, you need to make sure that you disable X Open Graph in X > Theme Options > Social to avoid Open Graph setup conflicts. Then, install and activate the X child theme. You can read more about that procedure at https://theme.co/apex/forum/t/setup-how-to-setup-child-themes/57

Once the child theme’s setup, add the code below to functions.php. My suggestion assumes that you understand a bit of PHP. If not, skip the coding and use a plugin. You can read more about that in this third-party article: https://kinsta.com/knowledgebase/add-code-wordpress-header-footer/.

/* Describe what the code snippet does so you can remember later on */
add_action('wp_head', 'your_function_name');
function your_function_name(){
?>
PASTE HEADER CODE HERE
<?php
};

Please note that the use of custom codes and third-party plugins are outside the scope of our product support. In case you encounter issues with them, please get in touch with the plugin developer or a web developer.

Hope that helps.

1 Like

That’s perfect, thank you!!!

You’re welcome, Giulia.

only a doubt sorry,
if I plan on using the plugin, is it still suggested to use the child theme?
Is it safe enough not using it or will it crash?

Hello Giulia,

If you plan to use a plugin to add the code in the <head> section of the site, you do not need the child theme. However, you may also leave the child theme active on the site just in case you will need to add some customization.

Hope this helps.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.