WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

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

I'm using the shopp e-commerce plugin. In my template file I need to get the id of the product (post). The online docs for shopp list shopp('product', 'id') but irritatingly this prints the id and there appears to be no alternative that simply returns it. Also confusing, when I do $post->ID it returns -42... which is weird.

Can anyone help me return the post id of individual products inside the shopp loop?


share|improve this question
up vote 1 down vote accepted

It's turns out that you can add return=true to any of the theme template tags:

shopp('product', 'id', 'return=true');

As of writing this, that is not mentioned in the documentation at all. Shopp support was also able to confirm that the $post->ID variable does get over-written in a number of situations, so the strange value I was seeing is not surprising.

share|improve this answer
a shorthand for this command would be shopp('product.get-id'); this works for every shopp() tag. – RST May 26 '15 at 13:49

This also works to get the current product's id:

$product_id = ShoppProduct()->id;

This is equivalent to:

$product_id = shopp('product','id','return=true');
share|improve this answer
It's not clear what you are trying to say with the answer. Please edit the Answer again and add some details with the code so that someone understand easily. – Mayeenul Islam Jan 2 '14 at 17:48

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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