Support

Account

Home Forums General Issues Trying to Add ACF Custom Field to Page Source Meta at the top For SEO Reply To: Trying to Add ACF Custom Field to Page Source Meta at the top For SEO

  • I would create an action in your functions.php file.

    
    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('your_field_name', $post_id);
      // your code to output meta tags here
    }