lifeIsGood
lifeIsGood

Reputation: 1229

How do you get woothemes shortcodes to work on an archive page of product attributes

I am not really sure how to ask this question, however if you have a look at this link you will see what I mean

http://www.skirentalwhistler.com/skill-level/beginner

You will see that the shortcodes for a [box] are not being executed.

If you browse a single product, the shortcode works fine - eg click on the first product called 'Compact' and you will see the [box] is executed into the grey box with one grey and one orange button in it.

Also, I have spent a few hours now trying to work out which template is creating this page. The page is a listing of all products with a certain product attribute value (attribute is skill-level and value is beginner) I expected it to be archive-product.php but it doesn't seem to be, and I can't find any other file dealing with multiple products on a single page

Any help is appreciated!

Upvotes: 0

Views: 1579

Answers (2)

lifeIsGood
lifeIsGood

Reputation: 1229

Ok, I have worked out how to do it. Big thanks to chiliNUT for their help, as they helped me to keep going and going.... thus I gave them an uptick

Anyway, it was using the themes archive.php template (not the woocommerce plugin templates as I presumed). In archive.php, I changed the following line in the div class 'entry'

<?php if ( $woo_options[ 'woo_post_content' ] == "content" ) the_content(__( 'Read More...', 'woothemes' )); else the_excerpt(); ?>

to

<?php echo apply_filters( 'woocommerce_short_description', $post->post_excerpt ) ?>

It now works and doesn't seem to have broken anything else.

Upvotes: 1

chiliNUT
chiliNUT

Reputation: 19573

When you are using a shortcode in a post, then the [box] syntax is what to use. However, if you are doing a shortcode in a template, you must execute the shortcode with php. Since your homepage appears to just display the short code instead of running it, then it is probably in a template. To execute a shortcode in a template, do this

<?php echo do_shortcode('[box]'); ?>

so for the one on your home page

<?php echo do_shortcode('[box size="small" style="rounded" border="full"]'); ?>

Upvotes: 1

Related Questions