How to Generate a Post Excerpt Outside the Loop
When you work with WordPress, you become pretty familiar with using the WP_Post object or objects for custom post types. For example, while working with WooCommerce, products use the WC_Product post object (or the object for a class that inherits this, such as WC_Product_Variation). If you’re in the loop while working with posts or custom post types, get_the_excerpt() is a beautiful function, as it returns the excerpt if it’s set by the user, and automatically…