Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Bradley-D/7287723 to your computer and use it in GitHub Desktop.
Save Bradley-D/7287723 to your computer and use it in GitHub Desktop.
// Get The Page ID You Need
get_option( 'woocommerce_shop_page_id' );
get_option( 'woocommerce_cart_page_id' );
get_option( 'woocommerce_checkout_page_id' );
get_option( 'woocommerce_pay_page_id' );
get_option( 'woocommerce_thanks_page_id' );
get_option( 'woocommerce_myaccount_page_id' );
get_option( 'woocommerce_edit_address_page_id' );
get_option( 'woocommerce_view_order_page_id' );
get_option( 'woocommerce_terms_page_id' );
// An Example
function get_shop_featured_image() {
if( is_shop() ) {
$shop = get_option( 'woocommerce_shop_page_id' );
if( has_post_thumbnail( $shop ) ) {
echo get_the_post_thumbnail( $shop );
}
}
}
// In You Templage File Place The Following
// Line To Call The WooCommerce Shop Featured Image
// Now You're Cooking With Gas - BOOM!!
<?php get_shop_featured_image(); ?>
@joelworsham
Copy link

Awesome! Thanks. Very useful.

@blickwert
Copy link

Thanks! 1+ 😄

@thegap81
Copy link

Hey guys...could you please tell me how to implement this?
I have one shop in English called 'shop' and one shop in Romanian called 'magazin'
I put the code in my functions.php file and the website goes down.
I really need your help please!? :(

@erezLieberman
Copy link

Thanks!

@KnightAlex
Copy link

thegap81 - this code doesn't go in functions.php. It might be used in a template where you are trying to use these page IDs

@moitorrijos
Copy link

Cool. Thanks. I was trying to get rid of a button in the shop that said Go to Store, and I was trying to use if ( ! is_page ( ID ) ... but it didin't work. after looking at this I use if ( ! is_shop() ) ... bang! disappeared!

@tatsujb
Copy link

tatsujb commented May 31, 2016

tried :

function new_nav_menu_items($items, $args) {
echo "args: <pre>"; print_r(get_option( 'woocommerce_shop_page_id' )); echo "</pre>";
    return $items;
}

got : "args : 4"

i also see 4 in the link to modify the shop page. however this :

.page-id-4 h1.page-title {

}

does nothing. while other page ids (in the four digit format) and not putting the id works.

I think I'm being returned the wrong ID.

EDIT: as it turns out, for shop you have to use

.archive.post-type-archive-product.woocommerce{

@LouVerdun
Copy link

Thanks !!! I've been looking for this for so long ^^

@abdo-host
Copy link

Thanks :)

@pakistanigeek
Copy link

Thank you man

@marketingchirino
Copy link

hola, como están?, estuve leyendo detenidamente sus comentarios pero no me resulta, el link View cart sigue tirandome solo un idioma, y esta parte del codigo no la entendi

tried :

function new_nav_menu_items($items, $args) {
echo "args:

"; print_r(get_option( 'woocommerce_shop_page_id' )); echo "
";
return $items;
}
got : "args : 4"

i also see 4 in the link to modify the shop page. however this :

.page-id-4 h1.page-title {

}
does nothing. while other page ids (in the four digit format) and not putting the id works.

I think I'm being returned the wrong ID.

EDIT: as it turns out, for shop you have to use

.archive.post-type-archive-product.woocommerce{

alguien que me pueda orientar?

@hideokamoto
Copy link

👍

@doubleedesign
Copy link

This is very helpful, thank you for sharing!

@strarsis
Copy link

strarsis commented Dec 2, 2017

Alternatively the recent wc_get_page_id(...) method can also be used.

@Amschabort
Copy link

Hi everyone,

I know this is long ago. But Im not sure where exactly to post the php code to get the WooC shop page id showing. Im not sure what Alexkwatson means but '..in a template where you are trying to use these page IDs'.

Can anyone help?

@sniperkill
Copy link

I am trying to get product ID, How to get product ID and check for conditions ?

@cyphix333
Copy link

Thank you so much!

@Tiex84
Copy link

Tiex84 commented Apr 11, 2019

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment