• Thank you for your ongoing work on this plugin.

    Could I request a simple update to enable support for the ‘primary category’, as set by Yoast for WooCommerce products (which in our case are often assigned to multiple categories)?

    It would sit within the gtm4wp_get_product_category() function and look something like this. There are catches in place so if Yoast is not active or the meta field is not set the original value would be returned

    if ( is_plugin_active( 'wordpress-seo/wp-seo.php' ) ) {
        $primary_cat_id = get_post_meta(get_the_ID(), '_yoast_wpseo_primary_' . 'product_cat', true);
        if ($primary_cat_id) {
            $primary_cat_obj = get_term_by('id', $primary_cat_id, 'product_cat');
            if (is_object( $primary_cat_obj )) {
                $product_cat = $primary_cat_obj->name;
            }
        }
    }
  • The topic ‘Request for support for Yoast ‘Primary’ categories’ is closed to new replies.