Viewing 2 replies - 1 through 2 (of 2 total)
  • You mean to use (long) description instead of the short description, right? You can do that with a code snippet which you can place in your functions.php file.

    add_filter(
    	'the_seo_framework_fetched_description_excerpt',
    	function( $excerpt, $d, $args ) {
    
    		$tsf = tsf();
    
    		if ( null === $args ) {
    			// In the loop.
    			$is_product = $tsf->is_product();
    		} else {
    			// Out the loop, admin etc.
    			$is_product = ! $args['taxonomy'] && ! $args['pta'] && $tsf->is_product( $args['id'] );
    		}
    
    		if ( $is_product ?? false ) {
    			$product    = get_post( $args['id'] ?? $tsf->get_the_real_ID() );
    			$product_id = $product->ID;
    
    			// Don't leak protected content.
    			if ( $tsf->is_protected( $product_id ) ) return $excerpt;
    
    			$old_excerpt = $excerpt;
    			$excerpt     = $tsf->uses_non_html_page_builder( $product_id ) ? '' : $product->post_content;
    
    			if ( $excerpt ) {
    				// Apply half of TSF's description AI here: selectively strip content and HTML.
    				$excerpt = $tsf->s_excerpt_raw(
    					$tsf->strip_paragraph_urls( $tsf->strip_newline_urls( $excerpt ) )
    				);
    			}
    			$excerpt = $excerpt ?: $old_excerpt;
    		}
    
    		return $excerpt;
    	},
    	10,
    	3
    );
    Plugin Author Sybre Waaijer

    (@cybr)

    Thanks, Johnny!

    The filter above will output deprecation notices from TSF v5.0.
    Here’s the updated version:

    add_filter(
    	'the_seo_framework_description_excerpt',
    	function( $excerpt, $args ) {
    
    		$tsf = tsf();
    
    		if ( null === $args ) {
    			// In the loop.
    			$is_product = $tsf->query()->is_product();
    		} else {
    			// Out the loop, admin etc.
    			$is_product = ! $args['taxonomy'] && ! $args['pta'] && $tsf->query()->is_product( $args['id'] );
    		}
    
    		if ( $is_product ?? false ) {
    			$product    = get_post( $args['id'] ?? $tsf->query()->get_the_real_id() );
    			$product_id = $product->ID;
    
    			$tsfpostdata = $tsf->data()->post();
    
    			// Don't leak protected content.
    			if ( $tsfpostdata->is_protected( $product_id ) )
    				return $excerpt;
    
    			$old_excerpt = $excerpt;
    			$excerpt     = $tsfpostdata->uses_non_html_page_builder( $product_id ) ? '' : $product->post_content;
    
    			if ( $excerpt ) {
    				$tsfhtml = $tsf->format()->html();
    				// Apply half of TSF's description AI here: selectively strip content and HTML.
    				$excerpt = $tsfhtml->extract_content( $tsfhtml->strip_paragraph_urls( $tsfhtml->strip_newline_urls(
    					$excerpt
    				) ) );
    			}
    			$excerpt = $excerpt ?: $old_excerpt;
    		}
    
    		return $excerpt;
    	},
    	10,
    	3
    );
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘WooCommerce Meta Description’ is closed to new replies.