Guest User

Untitled

a guest
Sep 10th, 2021
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.72 KB | None | 0 0
  1. add_action( 'rank_math/vars/register_extra_replacements', function() {
  2.     rank_math_register_var_replacement(
  3.         'woo_full_desc',
  4.         [
  5.             'name'        => esc_html__( 'Woo Full Desc.', 'rank-math' ),
  6.             'description' => esc_html__( 'Woo Full Description...', 'rank-math' ),
  7.             'variable'    => 'woo_full_desc',
  8.             'example'     => woo_full_desc_callback(),
  9.         ],
  10.         'woo_full_desc_callback'
  11.     );
  12. } );
  13. function woo_full_desc_callback() {
  14.     global $post;
  15.  
  16.     if ( empty( $post ) ) {
  17.         return 'Product Description';
  18.     }
  19.  
  20.     $product_description = substr(wp_strip_all_tags( $post->post_content ), 0, 169) . '...';
  21.  
  22.     return $product_description;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment