Get WooCommerce Page ID or URL

There’s quite a few posts out there on how to retrieve the URL or ID of WooCommerce pages, but I don’t see many that use the recommended functions bundled within WooCommerce.

Get a WooCommerce Page ID

Getting a page ID is simple:

If you try and request a page ID which does not exist, the function will return -1.

Get a WooCommerce Page URL

It’s just as simple to get the page URL (permalink):

If your requested page is not found, the function will return the home URL instead.

James is the founder of Iconic and an experienced WooCommerce plugin developer.


1 Comment

  1. CupidB says:

    Thanks It Was Helpful.

Leave a Reply

Your email address will not be published. Required fields are marked *