Use Woocommerce long description for meta

[ad_1]

Update: I got this sort of working.

  1. I had to change the code.
  2. Placing the code in rank-math.php creates the %wc_log_desc% short code but it did not work beyond that. I had to place the code in my child theme functions.php (at least for now)

Here is the code that worked for me:

function get_product_long_description() {
	$product_id = isset( $_GET['post'] ) ? $_GET['post'] : get_queried_object_id();
        $content_post = get_post($product_id);
        $desc = $content_post->post_content;
        $desc = apply_filters('the_content', $desc);
        $desc = str_replace(']]>', ']]>', $desc);
    return $desc;
}

Unfortunately, I still have to go to each product page, edit the snippet and enter %wc_log_desc%. For some reasons, doing on the Rank Math global SEO for product pages does not work, it still shows the short description.

Even changing the Default description for single Product pages to something like %title% does not change anything, is still displays the short description on each product.

  • This reply was modified 37 minutes ago by aaron843.
  • This reply was modified 35 minutes ago by aaron843.
  • This reply was modified 34 minutes ago by aaron843.

Update: Got it working on the front end. You have to override one more default behavior, here: https://support.rankmath.com/ticket/not-showing-meta-description/

Note: With this method, it will always show the full long description as the SEO snippet. Manually entering a custom snippet in Rank Math will no longer have any effect.

It’d be nice to see a walk-through of this in the Rank Math FAQ or something. When I was searching, I found this question a lot, but no single complete and up to date answer.

  • This reply was modified 4 minutes ago by aaron843.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer