Support

Account

Forum Replies Created

  • John, you’re awesome! That worked like a charm and was exactly was I was looking for.

    I sincerely appreciate you time, your detailed replies and your help with this.
    Thanks so much!

  • Hi John,

    Thanks so much for your time on this. I replaced the “// your code to output meta tags here” with the code above, and the following code was my block of text added to the functions.php of my child theme:

    add_action('wp_head', 'product_details_meta');
    function product_details_meta() {
      // get the queried object
      $queried_object = get_queried_object();
      // see if it's a post
      if (!is_a($queried_object, 'WP_POst')) {
        // not a post
        return;
      }
      // set $post_id
      $post_id = $queried_object->ID;
      // check post type
      if (get_post_type($post_id) != 'product') {
        // not a product
        return;
      }
      // use $post_id to get ACF field values
      $value = get_field('gtin', $post_id);
      if (get_field('gtin', $post_id)) {
      ?>
      <meta property="GTIN" content="<?php the_field(gtin', $post_id);?>" />
      <?php 
    }
    

    Sadly, it threw up a critical error on all pages of my site when I included this.

    If you happen to see anything glaring that I mistakenly did with the code above, please let me know. Once again, thanks for your time and your help is greatly appreciated. Thanks again.

  • Hi John,

    Thank you so much for your detailed reply.
    Since this type of coding exceeds my skill level, (translation: I’m kind of clueless) in the code above where commented out “// your code to output meta tags here”

    What would the sample code look like if, for example, my field was called “gtin” and I would like it to display the following in the source code:

    <meta property=”GTIN” content=”123456789112″ />

    If I could see an example of the code needed on that line, I could cut/paste and configure the rest for the other fields. Thank you for your time and help here!

  • Hi John, the custom fields are setup to only show on the product pages.

    They are included as data entry fields on the product entry area in the dashboard.
    (Attached are the fields I created)

    These work great when creating an XML feed for Google Shopping.

    I would just like these to appear in the header source code for greater SEO.

    Any help is appreciated, thanks!

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