How to get title of current page with woocommerce?

Member

by jasen , in category: PHP CMS , a year ago

How to get title of current page with woocommerce?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by aubrey , a year ago

@jasen 

To get the title of the current page with WooCommerce, you can use the following code snippet:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
global $wp;

// Get the post ID of the current page
$post_id = url_to_postid(home_url($wp->request));

// Get the post object for the current page
$post = get_post($post_id);

// Get the title of the current page
$title = $post->post_title;

// Output the title
echo $title;


You can add this code to your theme file (e.g. header.php or footer.php) or to a custom plugin to display the title of the current page on your WooCommerce website.

Related Threads:

How to get a page title which in iframe?
How to get current page name in wordpress?
How to get current page url in wordpress?
How to get current product category name in woocommerce?
How to add 'data-value' to the title of the page in wordpress?
How to get "terms & conditions" page id in woocommerce?