Support Data Stream

Data Stream

Forum Replies Created

Viewing 14 replies - 1 through 14 (of 14 total)
  • Hello Michael,

    Well the fix didn’t work initially. There was no ‘gtin13’ property manifesting in <script type=”application/ld+json”> on the product page. So I wondered about:
    if(isset($entity['isRelatedTo']))
    and decided I couldn’t see why it would be set. So now I have:

    /**
     * Filter to modify schema data.
     *
     * @param array $entity Snippet Data
     * @return array
     */
    add_filter( 'rank_math/snippet/rich_snippet_product_entity', function( $entity ) {
       
    	$entity['gtin13'] = str_replace('-', '',$entity['sku']);
    	$entity['offers']['priceValidUntil'] = '2020-12-31';
    	return $entity;
    });

    which works fine. I’ve extracted the script data from the page and it passes in the Google Structured Data Testing Tool. Terrific.

    And thank you for the ‘priceValidUntil’ property. WooCommerce only populates this with a sale price and we don’t have sale prices, so that’s an excellent solution for us.

    RankMath’s support has been diligent. Thank you.
    Barry

    Hello Michael and Todd,

    Hope you were able to take a holiday break. I’m back and refreshed, happily.

    So the code:

    
    /**
      * Customizing structured data using WooCommerce filters
    */
    add_filter( 'woocommerce_structured_data_product','add_gtin',10,2);
    function add_gtin( $markup, $product ) {
    
       $markup['gtin'] = str_replace('-', '',$markup['sku']);
       
       return $markup;
    };

    is under the plugin theme-customisations.php in custom/functions.php at the end.

    However, as stated this does not flow through to a ‘gtin’ in the structured data.

    Many thanks,
    Barry

    Hello,

    I have updated the sensitive data as requested. Can you please check further?

    Thank you.

    Hello Michael,

    Thank you to you, Todd and all your colleagues at Rank Math for perseverance with this issue. It is appreciated.

    I will follow the advice you’ve given, however, we have now arrived at the holiday season with family arriving today from all parts and for the present that becomes my priority. Hopefully, you will indulge me if I return to this after a short break.

    I see from the screen shot that you have a ‘Ticket Resolution’ prompt that I as a user don’t see? Maybe this ticket should revert to ‘not resolved’?

    Thank you again,
    Barry

    Hello Once More Todd,

    Oh dear!, Should have checked with the Google Structured Data Testing Tool before shouting Eureka. It’s more unhappy than ever and now has three warnings:

    warningbrand	
    The brand field is recommended. Please provide a value if available.
    warningsku	
    The sku field is recommended. Please provide a value if available.
    warning	
    This Product is missing a global identifier (e.g. isbn, mpn or gtin8). Please see documentation for valid identifiers.

    1. I’ll look into why we’ve lost brand in the update, maybe just needs re-selecting.
    2. ‘sku’ I can put back, so no problem there. As I said I’d replaced it with ‘gtin’.
    3. Although ‘gtin’ is mentioned in schema.org, maybe I need ‘isbn’? Will research further.

    When I’ve found out more I’ll raise a new ticket if necessary.

    Never easy.

    Best regards,
    Barry

    Hello Again Todd,

    Well, now there’s a thing, just updated to 10.0.36.1 and voilà, I now have ‘gtin’ and not ‘sku’. Wonders will never cease.

    Maybe some form of database update took place? I had previously tried saving the product, but to no avail. Anyway …

    Thank you,
    Barry

    Hi Todd,

    Thank you for your response, however, as I said originally, while the code adds to the $markup array, it has no effect on what is output to the ld+json script and thus Google Search Console is blind to it.

    I’m still seeing:
    <script type="application/ld+json">[{"@context":"https:\/\/schema.org\/","@type":"Product","sku":"978-0-9876451-0-4","name":"The Cheeky Possum","description":"A soft cover A4 landscape illustrated children's story about a possum who enjoys scaring people in the night time.\u00a0 Contains a dozen beautifully illustrated double page spreads of story and pictures.","releaseDate":"2018-03-29T10:42:24+11:00","brand":{"@type":"Thing","name":"Data Stream Pty Limited"},"url":"http:\/\/10.0.1.2\/child\/the-cheeky-possum\/","category":"Book Publisher","weight":{"@type":"QuantitativeValue","unitCode":"GRM","value":"180"},"height":{"@type":"QuantitativeValue","unitCode":"CMT","value":".4"},"width":{"@type":"QuantitativeValue","unitCode":"CMT","value":"30"},"depth":{"@type":"QuantitativeValue","unitCode":"CMT","value":"21"},"image":{"@type":"ImageObject","url":"http:\/\/10.0.1.2\/child\/wp-content\/uploads\/2018\/03\/CheekyPossum-cover.jpg","width":1123,"height":794},"aggregateRating":{"@type":"AggregateRating","ratingValue":"5.00","bestRating":"5","ratingCount":1,"reviewCount":1},"review":[{"@type":"Review","@id":"http:\/\/10.0.1.2\/child\/the-cheeky-possum\/#li-comment-499","description":"Delightful children's picture and story book. Full of light and shadow.","datePublished":"2019-10-03 10:18:17","reviewRating":{"@type":"Rating","ratingValue":5},"author":{"@type":"Person","name":"Barry Brunning","url":""}}],"offers":{"@type":"Offer","price":"15.00","priceCurrency":"AUD","availability":"https:\/\/schema.org\/InStock","itemCondition":"NewCondition","seller":{"@type":"Organization","@id":"http:\/\/10.0.1.2\/child\/","name":"Data Stream Pty Limited","url":"http:\/\/10.0.1.2\/child","logo":"http:\/\/10.0.1.2\/child\/wp-content\/uploads\/2018\/03\/DSdelta.png"},"url":"http:\/\/10.0.1.2\/child\/the-cheeky-possum\/","priceValidUntil":""},"additionalProperty":[{"@type":"PropertyValue","name":"pa_isbn","value":"978-0-9876451-0-4"},{"@type":"PropertyValue","name":"pa_publisher","value":"Data Stream Pty Limited"},{"@type":"PropertyValue","name":"pa_illustrator","value":"Paige Tilley, Rhiannon Tilley"},{"@type":"PropertyValue","name":"pa_seller","value":"Data Stream Pty Limited"},{"@type":"PropertyValue","name":"pa_seller_abn","value":"25 001 659 178"}]}]</script>
    with no sign of “gtin”.

    I have cleared the browser cache and as you will see this is a localhost test, so there’s no Cloudflare or hosting caches to confuse the issue.

    Maybe Rank Math is looking at $markup before the filter executes?

    I even tried replacing $markup[‘sku’] with $markup[‘gtin’] in case some array structure assumptions were being made (although I’m sure Rank Math developers do not commit such sins 😊). I’m confident in what I’ve done to $markup because I’ve checked the variable in phpStorm debugging mode.

    Best regards,
    Barry

    Hello Again Michael,

    Yes, setting noindex via the Advanced tab of the Rank Math metabox for the affected pages does the trick. Thank you.

    Along the way, I see that there is also a way to, presumably, achieve the same outcome by entering the post ID’s in the Exclude Posts field of the General tab of Sitemap Settings (the assistance there saying that it actually applies to posts, pages and custom post types).

    So it seems that Rank Math does have it all covered. But you do need to dig for the answers and can’t just install and forget, attractive as that is as a course of action.

    Regards,
    Barry

    Hi Michael,

    Thank you for your suggestion. As you may appreciate, for those not steeped in SEO, sitemaps and meta tags, all the options can be overwhelming. I will now do a test to see if a consistent (no Google aggravation) sitemap is produced.

    Obviously, if I can remove Google XML Sitemaps and achieve a good result using RankMath, then fewer plugins is better.

    Regards,
    Barry

    Hello Michael,

    Unfortunately, your reply does not answer my question about whether the RankMath sitemap detects and honours a ‘noindex’ setting. I don’t know whether that would be a reasonable expectation, but by inference, I’ll take it that it doesn’t.

    As I said in my question, I did not knowingly add the ‘noindex’ meta tags and I assume it’s WooCommerce that’s inserting them.

    It’s difficult not to be alarmed by a Submitted URL marked ‘noindex‘ report. As PepperLand Marketing and many others say “Don’t send Google mixed messages”, which strikes me as very sensible.

    In consequence of the above, I have turned off the sitemap in RankMath and installed the Google XML Sitemaps plugin. This plugin allows me to give ID’s of pages not to include in the sitemap. I’ve requested Google to retest the site and hope for no more red errors from them.

    Perhaps RankMath will enhance their sitemap capability in future to give an ability to exclude certain pages? Or does it already do that and I’ve missed it?

    Regards,
    Barry

    Hi Michael,

    Again I will stress the points 1, 2 and particularly 4 that I made in my list of shortcomings above. So, at this stage, the initial frontend solution implemented is the better and less confusing option. We’ll just have to tell our authors (presently few, but we aim for thousands over time) don’t worry, your name will appear in the structured data title. So, for me regrettably, it is pointless to follow your suggestion to check the results of this replacements change as we clearly will not be using that.

    Again, can I urge Rank Math to include a tag for the author’s display name usable for WooCommerce products. Also, again, observing that the %userid% tag does return the author id, so surely the plugin is halfway there?

    With the frontend solution, I’d overlooked to restrict it’s scope, so the currently implemented code is:

    
    /**
    * Filter to change the page title.
     * 
     * @param string $title
     */
    add_filter( 'rank_math/frontend/title', function( $title ) {
    
    	global $post;
    	
    	// Detect if it is a single post with a post author of custom type 'product'
    	if ( is_single() && isset( $post->post_author ) && (get_post_type() == 'product')) {
    		$title_len = strlen($title);
    		$bloginfo = get_bloginfo();
    		$bloginfo_len = strlen($bloginfo);
    	
    		$author_name = get_the_author_meta( 'display_name', $post->post_author);
    		$title = substr($title, 0, $title_len - ($bloginfo_len + 3)) . ' by ' . $author_name . substr($title, -1 * $bloginfo_len - 3);
    	}
    	
    	return $title;
    }); 
    

    Best regards,
    Barry

    Hello Michael,

    I thought we were on a winner here and was anxious to give congratulations, but regrettably, at this point, no.

    While the replacement of %name% has effect in SEO Titles and Meta/Products as shown in this screenshot, it does not carry through to the products, as shown here, where it is actually needed.

    This test is on localhost, so no caching beyond the browser is involved. I have cleared the browser cache. I tried testing the tag directly on the product, but %name% there is still returning the post title. I have also tried a new product, but as expected, %name% is still returning the title.

    Do we need a different filter, another array or what?

    Thank you for your suggestions so far,
    Barry

    Hello Michael,

    Thank you for your suggestion and in the absence of a better alternative, this is what I’ve done:

    /**
    * Filter to change the page title.
     * 
     * @param string $title
     */
    add_filter( 'rank_math/frontend/title', function( $title ) {
    
    	global $post;
    	
    	$title_len = strlen($title);
    	$bloginfo = get_bloginfo();
    	$bloginfo_len = strlen($bloginfo);
    	
    	$author_name = get_the_author_meta( 'display_name', $post->post_author);
    	$title = substr($title, 0, $title_len - ($bloginfo_len + 3)) . ' by ' . $author_name . substr($title, -1 * $bloginfo_len - 3);
    	return $title;
    });
    

    This does achieve the correct end result, that the title in the structured data is as we want for our book products, however there are shortcomings in this solution, as follows:

    1. This does not show the title correctly in the backend preview of the snippet.
    2. The SEO score for the title in the backend is consequently too low.
    3. I conjecture, in consequence, this will discourage us from displaying our SEO score.
    4. We aim to have our book authors configure their own products and this solution will confuse them unnecessarily.
    5. As a novice PHP and WordPress internals functionary this was frustrating, because I would like to have split the $title at the separator character. Apparently, this can be fetched using WPSEO_Utils::get_title_separator(), but on trying that my functions.php couldn’t find the class, so rather than waste more time I used the kludge shown.

    All these shortcomings mentioned would be overcome by having an %author% tag as suggested. Once more, I observe that, %userid% correctly returns the author id. Further, the author display name is readily available as I’ve shown. Therefore I suggest an %author% tag is a highly desirable enhancement.

    Best regards,
    Barry

    Hello Again,

    Don’t know what happened to the first screenshot, but here it is again.

    A preview of a ticket before posting would be helpful.

    Thank you,
    Barry

Viewing 14 replies - 1 through 14 (of 14 total)