Title: product shortcode problems
Last modified: May 18, 2021

---

# product shortcode problems

 *  Resolved [peteratomic](https://wordpress.org/support/users/peteratomic/)
 * (@peteratomic)
 * [5 years ago](https://wordpress.org/support/topic/product-shortcode-problems/)
 * Am using a shortcode to display five products that are hidden from regular inventory:
 * [products limit=”5″ columns=”5″ ids=”5097,5095,5084,5085,5083″ visibility=”hidden”]
 * Everything renders fine, except that the add to cart links are outputting as “
   buy now” links where the product is added to the cart rather than clicking through
   to the product page, which is the default behavior for the whole site:
 * Meaning the links are: /hand-picked-for-you/?add-to-cart=5084
 * Rather than a link to the product page: /product/copal-oil/
 * Only one of the products works properly, the difference being that it has a variation.
   In this case, the link generated goes to the product page as intended.
 * Unfortunately I can’t share the page as its a special offer that my client wants
   hidden from regular view.

Viewing 7 replies - 1 through 7 (of 7 total)

 *  Thread Starter [peteratomic](https://wordpress.org/support/users/peteratomic/)
 * (@peteratomic)
 * [5 years ago](https://wordpress.org/support/topic/product-shortcode-problems/#post-14451310)
 * Followed from the documentation here: [https://docs.woocommerce.com/document/woocommerce-shortcodes/#section-9](https://docs.woocommerce.com/document/woocommerce-shortcodes/#section-9)
 *  Thread Starter [peteratomic](https://wordpress.org/support/users/peteratomic/)
 * (@peteratomic)
 * [5 years ago](https://wordpress.org/support/topic/product-shortcode-problems/#post-14451538)
 * Actually found that this is happening on ALL product links, not just shortcodes.
   Tried disabling plugins and using storefront, but neither helped. Tried permalink
   reset, no help.
 *  Thread Starter [peteratomic](https://wordpress.org/support/users/peteratomic/)
 * (@peteratomic)
 * [5 years ago](https://wordpress.org/support/topic/product-shortcode-problems/#post-14451889)
 * Also noticed something odd… whether using storefront or our regular theme, the
   link on the product image is correct:
 * [https://fourvisionsmarket.com/product/handmade-one-of-a-kind-seed-bead-earrings-7/](https://fourvisionsmarket.com/product/handmade-one-of-a-kind-seed-bead-earrings-7/)
 * But the Add to Cart button is:
    [https://fourvisionsmarket.com/product-category/feminine-tools/earrings-feminine-tools/?add-to-cart=987468929](https://fourvisionsmarket.com/product-category/feminine-tools/earrings-feminine-tools/?add-to-cart=987468929)
 * Tried two or three times to do plugin + theme resets, but that had no effect.
 *  [3 Sons Development](https://wordpress.org/support/users/3sonsdevelopment/)
 * (@3sonsdevelopment)
 * [5 years ago](https://wordpress.org/support/topic/product-shortcode-problems/#post-14460176)
 * Hi [@peteratomic](https://wordpress.org/support/users/peteratomic/),
 * You may be able to adjust this with the `woocommerce_loop_add_to_cart_link` filter.
   Here’s the source code for that.
 *     ```
       echo apply_filters(
       	'woocommerce_loop_add_to_cart_link', // WPCS: XSS ok.
       	sprintf(
       		'<a href="%s" data-quantity="%s" class="%s" %s>%s</a>',
       		esc_url( $product->add_to_cart_url() ),
       		esc_attr( isset( $args['quantity'] ) ? $args['quantity'] : 1 ),
       		esc_attr( isset( $args['class'] ) ? $args['class'] : 'button' ),
       		isset( $args['attributes'] ) ? wc_implode_html_attributes( $args['attributes'] ) : '',
       		esc_html( $product->add_to_cart_text() )
       	),
       	$product,
       	$args
       );
       ```
   
 * You’d want to write a function that replaces the generated link with one that
   redirects to the single product page instead.
 *  Thread Starter [peteratomic](https://wordpress.org/support/users/peteratomic/)
 * (@peteratomic)
 * [5 years ago](https://wordpress.org/support/topic/product-shortcode-problems/#post-14466996)
 * Thank you [@3sonsdevelopment](https://wordpress.org/support/users/3sonsdevelopment/)!
 * Curious though… was this something that changed with a new version of Woocommerce?
   The default we’ve had since launch was a product page link on the add to cart
   button, then it suddenly changed, but can’t say exactly when.
 *  [3 Sons Development](https://wordpress.org/support/users/3sonsdevelopment/)
 * (@3sonsdevelopment)
 * [5 years ago](https://wordpress.org/support/topic/product-shortcode-problems/#post-14467536)
 * Good question. It’s been this way for quite some time though I can’t say for 
   certain if/when it changed. You’re welcome to go back through the history of 
   the file on GitHub to see exactly what changed when.
 * [https://github.com/woocommerce/woocommerce/commits/d48f1d4e2efcfab8206799df2085f021ec273722/templates/loop/add-to-cart.php](https://github.com/woocommerce/woocommerce/commits/d48f1d4e2efcfab8206799df2085f021ec273722/templates/loop/add-to-cart.php)
 *  Plugin Support [abwaita a11n](https://wordpress.org/support/users/abwaita/)
 * (@abwaita)
 * [5 years ago](https://wordpress.org/support/topic/product-shortcode-problems/#post-14494361)
 * Hi,
 * Since the thread has been inactive for a while, I’ll go ahead and mark it as 
   resolved. Hopefully, the above info was helpful!
 * If you have further questions, please feel free to open a new topic.
 * Thanks.

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘product shortcode problems’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce/assets/icon.svg?rev=3234504)
 * [WooCommerce](https://wordpress.org/plugins/woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce/reviews/)

 * 7 replies
 * 3 participants
 * Last reply from: [abwaita a11n](https://wordpress.org/support/users/abwaita/)
 * Last activity: [5 years ago](https://wordpress.org/support/topic/product-shortcode-problems/#post-14494361)
 * Status: resolved