Home › Forums › WoodMart support forum › How do you add a meta tag to the head?
How do you add a meta tag to the head?
- This topic has 5 replies, 3 voices, and was last updated 10 months, 3 weeks ago by
Luke Nielsen.
-
AuthorPosts
-
November 26, 2021 at 3:19 pm #334937
kalonji1ParticipantI need to add a code and the article says:
Add a meta-tag
Verify this domain by copying and pasting the provided meta-tag code into the <head> … <head> section of your website’s home page HTML code.How can I do this? Thanks!
November 26, 2021 at 4:01 pm #334950
Luke NielsenKeymasterHello,
In order to add some meta tag into the
<head>
section, navigate to woodmart\header.php. At the very beginning of the file you will see it.https://monosnap.com/file/IFI5gWM12U4NEIIsJ2h3wxW4QjTBRs
Kind Regards
November 15, 2023 at 4:56 pm #512613
MatimtiParticipantHi!
Can I add the Facebook meta tag to a child theme?
Is it possible to create something similar with a Google tag?
I’m afraid that everything will be lost during the update, how do you recommend doing it?
November 16, 2023 at 10:32 am #512767
Luke NielsenKeymasterHello,
The below article will help you to add your own meta tag:
https://hoolite.be/wordpress/add-custom-meta-tags-to-via-functions-php/
If you do not want to lose your changes, you need to add the custom code to the functions.php file in your child theme.
Kind Regards
June 5, 2024 at 2:51 am #570668
serkanisimParticipantadd those codes to functions.php
###For both WooCommerce and WordPress you will use:
add_action( ‘wp_head’, ‘wcs_add_meta_keywords’ , 2 );
function wcs_add_meta_keywords() {
// For WordPress single posts with categories and tags
if ( is_single() && ! is_product() ) {
$cats = (array) wp_get_post_terms( get_the_id(), ‘category’, array(‘fields’ => ‘names’) );
$tags = (array) wp_get_post_terms( get_the_id(), ‘post_tag’, array(‘fields’ => ‘names’) );
}
// For WooCommerce single product (product categories and product tags)
elseif ( is_product() ) {
$cats = (array) wp_get_post_terms( get_the_id(), ‘product_cat’, array(‘fields’ => ‘names’) );
$tags = (array) wp_get_post_terms( get_the_id(), ‘product_tag’, array(‘fields’ => ‘names’) );
}
if ( ! empty( $cats ) || ! empty( $tags ) ){
echo ‘<meta name=”keywords” content=”‘ . implode( ‘, ‘, array_merge( $cats, $tags ) ) . ‘” />’ . “\n”;
}
}####For WooCommerce only use:
add_action( ‘wp_head’, ‘wcs_add_meta_keywords’, 2);
function wcs_add_meta_keywords() {
if ( is_product() ) {
$product_cats = (array) wp_get_post_terms( get_the_id(), ‘product_cat’, array(‘fields’ => ‘names’) );
$product_tags = (array) wp_get_post_terms( get_the_id(), ‘product_tag’, array(‘fields’ => ‘names’) );
}
if ( ! empty( $product_cats ) || ! empty( $product_tags ) ){
echo ‘<meta name=”keywords” content=”‘ . implode( ‘, ‘, array_merge( $product_cats, $product_tags ) ) . ‘” />’ . “\n”;
}
}June 5, 2024 at 11:03 am #570741
Luke NielsenKeymasterHello,
Great! Glad that you have sorted it out.
You can also reach out to us if you have any questions.
Kind Regards
-
AuthorPosts
The topic ‘How do you add a meta tag to the head?’ is closed to new replies.
- You must be logged in to create new topics. Login / Register