Filter to add something if description is empty
-
Hi, I have a client with several products (and variations) that may not contain a long or short description. I’m wondering if I can apply a filter to add something generic to the feed if a product doesn’t have a long description or short description.
Here is what I have but I’m getting an error when generating my feed that reads: Call to a member function get_short_description() on bool
add_filter( 'aepc_feed_item_description', function( $description, $item ) { $post = get_post( $item->get_id() ); if ( ! empty( $post->post_parent ) ) { $post = get_post( $post->post_parent ); } $product = wc_get_product($post); $description = $product->get_short_description(); if ( empty($description ) ) { $description = 'Shop ' . $product->get_title(); } return $description; }, 10, 2 );
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Filter to add something if description is empty’ is closed to new replies.