Receive full size product by product name, Woocommerce

I am trying to get a Woocommerce product based on the given product name. I know that I can get the permalink using the product identifier as follows:

$url = get_permalink( $product_id ); 

But I can’t find the code to get it by product name. I tried this:

 $url = get_permalink( 'title' ); 

This does not work. Please, help.

+6
source share
2 answers

This code works for me

 $product = get_page_by_title( 'Product Title', OBJECT, 'product' ) echo get_permalink( $product->ID ); 
+10
source

For URL:

 $url = get_permalink($product_id) 

For the title:

 $name = get_the_title($product_id) 
+1
source

Source: https://habr.com/ru/post/972805/


All Articles