Title: Shortcode to display YMM plugin
Last modified: January 4, 2024

---

# Shortcode to display YMM plugin

 *  Resolved [kxeilakos](https://wordpress.org/support/users/kxeilakos/)
 * (@kxeilakos)
 * [2 years, 5 months ago](https://wordpress.org/support/topic/shortcode-to-display-ymm-plugin/)
 * Hi there,
 * first, I wish you a Happy new Year! 
   I am building a custom page using Elementor
   builder. Is it possible to display the YMM dropdowns inside this page, or using
   a sidebar or a widget in general is mandatory?
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fshortcode-to-display-ymm-plugin%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

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

 *  Plugin Author [Pektsekye](https://wordpress.org/support/users/pektsekye/)
 * (@pektsekye)
 * [2 years, 5 months ago](https://wordpress.org/support/topic/shortcode-to-display-ymm-plugin/#post-17317875)
 * Hello,
 * You should be able to add it with shortcode:
 *     ```
       [ymm_selector template="horizontal_selector.php"]
       ```
   
 * Stanislav
 *  Thread Starter [kxeilakos](https://wordpress.org/support/users/kxeilakos/)
 * (@kxeilakos)
 * [2 years, 5 months ago](https://wordpress.org/support/topic/shortcode-to-display-ymm-plugin/#post-17328116)
 * Yes, it works, thank you very much for your instant response. I placed it on 
   a custom page and once it retrieves the products it redirects to the category/
   cart page to display the grid.
 * Is it possible to display the products on the same page on a grid without re-
   directing to the category / cart page?
 * this is my page: [https://krikellas.gr/black-friday/](https://krikellas.gr/black-friday/)
 * There is a Horizontal YMM filter and an Archive Products element below the filter.
   Is it possible to display the filtered products in the specific grid and remain
   on the /black-friday/ page ?
 *  Plugin Author [Pektsekye](https://wordpress.org/support/users/pektsekye/)
 * (@pektsekye)
 * [2 years, 5 months ago](https://wordpress.org/support/topic/shortcode-to-display-ymm-plugin/#post-17328229)
 * Hello,
 * To make it redirect to a custom page as search results page:
 * Try to replace the line:
 *     ```
        return home_url( '/' );
       ```
   
 * with:
 *     ```
        return home_url( '/black-friday/' );
       ```
   
 * in the file:
    wp-content/plugins/ymm-search/Block/Selector.php`
 * –
 * Then use a shortcode like this:
 *     ```
       [products]
       ```
   
 * To display products on your custom wordpress page.
 * –
 * To make those products filtered by the current selected make, make and year:
   
   Add the line:
 *     ```
           add_filter( 'woocommerce_shortcode_products_query', array($this, 'filter_shortcode_products_query' ));
       ```
   
 * after the line:
 *     ```
       add_filter('get_search_query', array($this, 'shop_order_search_label' ));
       ```
   
 * And add the code:
 *     ```
       public function filter_shortcode_products_query($query_args) {
   
           $values = $this->getSelectedValues();
           $pIds = $this->getFoundProductIds();
   
           if (count($values) > 0){
             $query_args['post__in'] = count($pIds) > 0 ? $pIds : array(-1); // -1 to display a "no products found" message
           }
   
           return $query_args;		
         }
       ```
   
 * before the line:
 *     ```
         public function applyFilter(){
       ```
   
 * in the file:
    wp-content/plugins/ymm-search/Controller/Product.php
 * –
 * NOTE: You can add attributes to the products shortcode like “columns”, “orderby”:
   
   [https://woocommerce.com/document/woocommerce-shortcodes/#available-product-attributes](https://woocommerce.com/document/woocommerce-shortcodes/#available-product-attributes)
 * Stanislav
 *  Thread Starter [kxeilakos](https://wordpress.org/support/users/kxeilakos/)
 * (@kxeilakos)
 * [2 years, 5 months ago](https://wordpress.org/support/topic/shortcode-to-display-ymm-plugin/#post-17328630)
 * Great resposne! Thank you very much. I really appreciate your help on this!
 *  [huusoku](https://wordpress.org/support/users/huusoku/)
 * (@huusoku)
 * [2 years, 4 months ago](https://wordpress.org/support/topic/shortcode-to-display-ymm-plugin/#post-17358616)
 * [@pektsekye](https://wordpress.org/support/users/pektsekye/), first, thank you
   SO MUCH for this plug-in. I’d like to send you $$ once I get it working on our
   new website. I am also using Elementor and am following your instructions here.
 * Our issue is that when you enter an application and click Search, it only just
   loads the Elementor Archives product category view with all categories present
   without any filtering being applied.
 * I decided to try the notes above in this thread by creating a new ordinary Page
   and inserting both the YMM shortcode as “[ymm_selector template=”selector.php”
   garage=1]” and below that the products shortcode as “[products]”.
 * When I load the page, for example “www.site.com**/select-your-vehicle**“, the
   page takes a very long time to load as it displays all 1000+ of our products 
   without any category structure. Then, when I make a selection and click Search,
   it loads a 404 page for “Page not found” despite still being on the proper URL
   of, for example, “www.site.com**/select-your-vehicle**?ymm_search=1&post_type
   =product&_make=Toyota&_model=Tacoma&_year=2018″
 * Line 256 of my Block/Selector.php is: “return home_url( ‘/select-your-vehicle/’);”
 * Thank you for the assistance!
 *  Plugin Author [Pektsekye](https://wordpress.org/support/users/pektsekye/)
 * (@pektsekye)
 * [2 years, 4 months ago](https://wordpress.org/support/topic/shortcode-to-display-ymm-plugin/#post-17358688)
 * Hello,
 * To: [@huusoku](https://wordpress.org/support/users/huusoku/)
 * Can you send a link of your website to my email [pektsekye@gmail.com](https://wordpress.org/support/topic/shortcode-to-display-ymm-plugin/pektsekye@gmail.com?output_format=md)
 * ?
 * Stanislav
 *  [huusoku](https://wordpress.org/support/users/huusoku/)
 * (@huusoku)
 * [2 years, 4 months ago](https://wordpress.org/support/topic/shortcode-to-display-ymm-plugin/#post-17360516)
 * Thank you for the help, Stanislav!! Excellent support. My issue was that despite
   what I posted above 😂🤦🏽‍♂️, I actually had in my Selector.php file:
 * `return home_url( '/select-your-vehicle' );`
 * instead of
 * `return home_url( '/select-your-vehicle/' );`
 * Once I added that trailing ‘/’ it worked. Stanislav then also provided a tip 
   to replace “.done” with “.success” in main.js and now it is functioning as expected.
 * Another tip which is not new to many but was new to me is that the [products]
   shortcode can be improved with pagination, for example, [products paginate=”true”
   limit=25], so that your poor server doesn’t try to load your entire database 
   of products 😅
 * Next, I am working on a way to have a “Remove Vehicle” option to remove the currently
   selected vehicle from the garage as well as how to get YMM to function with the
   Elementor widget “Archive Products”, which provides a Category view instead of
   a bunch of dumped, unsorted product view through the [products] shortcode method.
 * I’ll keep this updated to help others, and thank you again Stanislav! Looking
   forward to having this fully set up!
 * Regards,
   Huusoku
    -  This reply was modified 2 years, 4 months ago by [huusoku](https://wordpress.org/support/users/huusoku/).
    -  This reply was modified 2 years, 4 months ago by [huusoku](https://wordpress.org/support/users/huusoku/).

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

The topic ‘Shortcode to display YMM plugin’ is closed to new replies.

 * ![](https://ps.w.org/ymm-search/assets/icon-256x256.png?rev=1750193)
 * [Year Make Model Search for WooCommerce](https://wordpress.org/plugins/ymm-search/)
 * [Support Threads](https://wordpress.org/support/plugin/ymm-search/)
 * [Active Topics](https://wordpress.org/support/plugin/ymm-search/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/ymm-search/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/ymm-search/reviews/)

 * 7 replies
 * 3 participants
 * Last reply from: [huusoku](https://wordpress.org/support/users/huusoku/)
 * Last activity: [2 years, 4 months ago](https://wordpress.org/support/topic/shortcode-to-display-ymm-plugin/#post-17360516)
 * Status: resolved