Default meta seo description for woocommerce products.

#170801
  • Resolved Wojtek Czaja
    Rank Math free

    Rank Math by default tells me the meta seo description of woocommerce products as %excerpt%

    The products do not have a sneak peak, will the product description be downloaded as the meta seo description??

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

    Thanks for contacting us. Sorry for the delay and any inconvenience that might have been caused due to that.

    If the meta description is set as %excerpt% then it will be generated from the Product Short Description. If your product doesn’t have any short description then your product description will be used as SEO description.

    Hope this helps. Let us know if you need any further assistance.

    How to set the full product description to be SEO??

    Hello,

    Thanks for getting back.

    You can create a custom variable for the full product description by adding the code given below to your theme’s/child theme’s functions.php file

    add_action( 'rank_math/vars/register_extra_replacements', function() {
    	rank_math_register_var_replacement(
    		'woo_full_desc',
    		[
    			'name'        => esc_html__( 'Woo Full Desc.', 'rank-math' ),
    			'description' => esc_html__( 'Woo Full Description...', 'rank-math' ),
    			'variable'    => 'woo_full_desc',
    			'example'     => woo_full_desc_callback(),
    		],
    		'woo_full_desc_callback',
    	);
    } );
    function woo_full_desc_callback() {
    	global $post;
    	if ( empty( $post ) ) {
    		return 'Product Description';
    	}
    
    	return wp_strip_all_tags( $post->post_content );
    }

    After this add %woo_full_desc% in the SEO description field of the snippet editor

    This will set the full product description as meta description.

    Hope this helps. Let us know if you need any further assistance.

    I got an error after I entered it

    The PHP code changes made have been reverted due to a bug in line 32 in wp-content / themes / shoppingcart-child / functions.php. Please fix the error and try to save again.

    syntax error, unexpected ‘)’

    The contents of the functions.php file

    <?php
    add_action( 'wp_enqueue_scripts', 'enqueue_parent_styles' );
    function enqueue_parent_styles() {
        wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' );
    }
    /**
    * @snippet Change WooCommerce ‘Add to Cart’ button to 'View Product'
    * @source https://www.wptechnic.com/?p=4615
    * @author Muhammad Tamzid
    * @compatible WC 4.3.1
    */
    // Change WooCommerce 'Add To Cart' button to 'View Product'
    add_filter( 'woocommerce_loop_add_to_cart_link', 'wpt_custom_view_product_button', 10, 2 );
    function wpt_custom_view_product_button( $button, $product  ) {
    // Ignore for variable products
    if( $product->is_type( 'variable' ) ) return $button;
    // Button text here
    $button_text = __( "View product", "woocommerce" );
        return '<a class="button wpt-custom-view-product-button" href="' . $product->get_permalink() . '">' . $button_text . '</a>';	
    }
    
    add_action( 'rank_math/vars/register_extra_replacements', function() {
    	rank_math_register_var_replacement(
    		'woo_full_desc',
    		[
    			'name'        => esc_html__( 'Woo Full Desc.', 'rank-math' ),
    			'description' => esc_html__( 'Woo Full Description...', 'rank-math' ),
    			'variable'    => 'woo_full_desc',
    			'example'     => woo_full_desc_callback(),
    		],
    		'woo_full_desc_callback',
    	);
    } );
    function woo_full_desc_callback() {
    	global $post;
    	if ( empty( $post ) ) {
    		return 'Product Description';
    	}
    
    	return wp_strip_all_tags( $post->post_content );
    }
    ?>

    Hello,

    Thank you for keeping in touch with us.

    We might need to take a closer look at the settings. Please edit the first post on this ticket and include your WordPress & FTP logins in the designated Sensitive Data section.
    Sensitive Data Section

    It is completely secure and only our support staff has access to that section. If you want, you can use the below plugin to generate a temporary login URL to your website and share that with us instead:

    https://wordpress.org/plugins/temporary-login-without-password/

    You can use the above plugin in conjunction with the WP Security Audit Log to monitor what changes our staff might make on your website (if any):

    https://wordpress.org/plugins/wp-security-audit-log/

    We really look forward to helping you.

    Hello,

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

    Thank you.

    yyyyy no, is there any other way to point you out to the problem and how to fix it.

    Hello,

    Thank you for the follow-up, and sorry for the delay.

    It seems that there’s an excess comma in the function (rank_math_register_var_replacement) parameters. Could you please try removing that and see if the issue still persists?
    Comma

    Here’s a screencast for your reference:
    https://i.rankmath.com/f6sp0i

    I hope that helps. Thank you, and looking forward to your update.

    Thanks a lot, it works.
    Rank Math support you guys are very helpful.

    Anas
    Rank Math business

    Hello,

    We are super happy that your issue is resolved. If you have any other questions in the future, know that we are here to help you.

    If you don’t mind me asking, could you please leave us a review (if you haven’t already) on https://wordpress.org/support/plugin/seo-by-rank-math/reviews/#new-post about your overall experience with Rank Math? We appreciate your time and patience.

    If you do have another question in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you again.

    Thank you.

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

The ticket ‘Default meta seo description for woocommerce products.’ is closed to new replies.