WC_Post_Data::variation_post_link()
Link to parent products when getting permalink for variation.
Method of the class: WC_Post_Data{}
No Hooks.
Return
String
.
Usage
$result = WC_Post_Data::variation_post_link( $permalink, $post );
- $permalink(string) (required)
- Permalink.
- $post(WP_Post) (required)
- Post data.
WC_Post_Data::variation_post_link() WC Post Data::variation post link code WC 9.7.1
public static function variation_post_link( $permalink, $post ) { if ( isset( $post->ID, $post->post_type ) && 'product_variation' === $post->post_type ) { $variation = wc_get_product( $post->ID ); if ( $variation && $variation->get_parent_id() ) { return $variation->get_permalink(); } } return $permalink; }