WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Say I have the ID of a product in wooCommerce; can I generate its URL somehow? (example /shop/fresh-apples)

share|improve this question
up vote 9 down vote accepted

Products in WooCommerce are a custom post type, so this should work:

$url = get_permalink( $product_id );

You can treat that $product_id as a postID (that's what it is), so you can use it with other normal WP functions, like:

echo '<a href="'.get_permalink($product_id).'">'.get_the_title($product_id).'</a>';
share|improve this answer

protected by toscho Oct 10 '14 at 11:11

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.