in post content shortcode works, but hardcoded in same page template doesn’t?

Question

So I have a super simple Woocommerce shortcode [product_categories], It’s supposed to show product categories from the shop.

It does this job perfectly if I put it inside the contents of a page as such: [product_categories].

However, if I put the same thing into the template directly it suddenly returns the first post of current category? What?!

So in my template I have only these two rows:

<?php echo do_shortcode('[product categories]'); // this returns a single product which is wrong and totally weird ?>
<?php the_content(); // this returns the categories as intended ?>

I never knew these two methods have some kind of difference. How can I make the shortcode work with the echo way?

0
, , Jussi 3 years 2019-10-28T08:16:10-05:00 0 Answers 74 views 0

Leave an answer

Browse
Browse