Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conditional Tag for a specific Single Product in Shop #1300

Closed
richangel opened this issue Jul 25, 2012 · 3 comments
Closed

Conditional Tag for a specific Single Product in Shop #1300

richangel opened this issue Jul 25, 2012 · 3 comments

Comments

@richangel
Copy link

Hi everyone,

I am using the widget logic plugin to display different text widgets in different product categories - so far so good, this works excellent, by simply adding the product category conditional tag --> is_product_category('xyz') into the widget logic field below the according widget.

However, I was not able to make this possible for a specific product in woocommerce. Using this conditional tag: is_product () will solely then show the widget in ALL product pages.

Is there any way to target a specific product, using the unique product ID?

This is what I currently have for regular php:

function check_specific_page() {
global $product;

if( $product->id == 1 && is_product() )
    die( 'I\'m showing only on single product page with id 1' );

}

Adding $product->id == 1 && is_product() into the widget logic field however does not work.

I really hope you can help...basically what I need is the conditional tag for a specific product.

Thanks so much,
Rich

@mikejolley
Copy link
Member

Use is_single - its a WP conditional.

@richangel
Copy link
Author

Worked like a charm! Great! I really searched for hours and this simple ID works - so to target a single product, simply use is_single(ID)

@izzycart
Copy link

Works like charm... is_single(ID) ... just like @richangel, i have dived into different articles for hours and i am glad i opened this link. Thanks so much @mikejolley

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants