Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// 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

This comment has been minimized.

Copy link

@joelworsham joelworsham commented Apr 24, 2015

Awesome! Thanks. Very useful.

@blickwert

This comment has been minimized.

Copy link

@blickwert blickwert commented Apr 27, 2015

Thanks! 1+ 😄

@thegap81

This comment has been minimized.

Copy link

@thegap81 thegap81 commented Sep 20, 2015

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

This comment has been minimized.

Copy link

@erezLieberman erezLieberman commented Dec 23, 2015

Thanks!

@KnightAlex

This comment has been minimized.

Copy link

@KnightAlex KnightAlex commented Jan 2, 2016

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

This comment has been minimized.

Copy link

@moitorrijos moitorrijos commented Jan 24, 2016

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

This comment has been minimized.

Copy link

@tatsujb 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

This comment has been minimized.

Copy link

@LouVerdun LouVerdun commented Jul 30, 2016

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

@abdo-host

This comment has been minimized.

Copy link

@abdo-host abdo-host commented Aug 17, 2016

Thanks :)

@pakistanigeek

This comment has been minimized.

Copy link

@pakistanigeek pakistanigeek commented Aug 25, 2016

Thank you man

@marketingchirino

This comment has been minimized.

Copy link

@marketingchirino marketingchirino commented Oct 7, 2016

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

This comment has been minimized.

Copy link

@hideokamoto hideokamoto commented Jan 31, 2017

👍

@doubleedesign

This comment has been minimized.

Copy link

@doubleedesign doubleedesign commented May 29, 2017

This is very helpful, thank you for sharing!

@strarsis

This comment has been minimized.

Copy link

@strarsis strarsis commented Dec 2, 2017

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

@Amschabort

This comment has been minimized.

Copy link

@Amschabort Amschabort commented Mar 20, 2018

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

This comment has been minimized.

Copy link

@sniperkill sniperkill commented Apr 14, 2018

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

@cyphix333

This comment has been minimized.

Copy link

@cyphix333 cyphix333 commented Mar 4, 2019

Thank you so much!

@Tiex84

This comment has been minimized.

Copy link

@Tiex84 Tiex84 commented Apr 11, 2019

Thanks!

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