A
A
Anton Chernogolov2020-02-14 22:45:32
WordPress
Anton Chernogolov, 2020-02-14 22:45:32

How to determine in woocommerce that the current page is a product?

How can we determine in the functions.php file that we are on the product page.
is_product() function - always returns NULL
A construct

global $product;
$id = $product->get_id();

generally returns an error. It doesn't matter which page we're on.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Arthur Khylskyi, 2020-02-15
@ArthurPatriot

What hook are you hooking the function to? Use hooks starting with action - init.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question