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?

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #334937

    kalonji1
    Participant

    I 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!

    #334950

    Luke Nielsen
    Keymaster

    Hello,

    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

    #512613

    Matimti
    Participant

    Hi!

    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?

    #512767

    Luke Nielsen
    Keymaster

    Hello,

    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

    #570668

    serkanisim
    Participant

    add 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”;
    }
    }

    #570741

    Luke Nielsen
    Keymaster

    Hello,

    Great! Glad that you have sorted it out.

    You can also reach out to us if you have any questions.

    Kind Regards

Viewing 6 posts - 1 through 6 (of 6 total)

The topic ‘How do you add a meta tag to the head?’ is closed to new replies.