Title: Get global JS filter function
Last modified: August 19, 2026

---

# Get global JS filter function

 *  Resolved [fredericv](https://wordpress.org/support/users/fredericv/)
 * (@fredericv)
 * [2 weeks, 2 days ago](https://wordpress.org/support/topic/get-global-js-filter-function/)
 * Hello,
 * I would like to create some special pages, with posts already filtered on it.
 * For example :
    - I have a taxonomy “Fruit” with “apple, orange, pineapple”
    - I have a page “Fruits” with a YMC Filter that filters articles by fruit : 
      there are buttons on it to filter by fruit
 * -> I would like to know how is it possible to have a page “Apple”, the same as“
   Fruits”, but with “Apple” already filtered on it ?
 * Many thanks

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

 *  Plugin Author [YMC](https://wordpress.org/support/users/wssoffice21/)
 * (@wssoffice21)
 * [2 weeks, 2 days ago](https://wordpress.org/support/topic/get-global-js-filter-function/#post-18997585)
 * Hi!
   To load specific posts for specific tags (terms) on specific pages, you should
   select the desired terms in the plugin settings and then click the three dots
   on the right side of the desired term. A pop-up will open, and inside, select
   the Default Term option. (The Default Term is applied only for the initial grid
   load and is not used after filtering or resetting filters.) This will allow you
   to initially load posts that belong to the default term. We hope this helps.
 *  Thread Starter [fredericv](https://wordpress.org/support/users/fredericv/)
 * (@fredericv)
 * [2 weeks, 2 days ago](https://wordpress.org/support/topic/get-global-js-filter-function/#post-18997647)
 * Yes it’s perfect, many thanks !
 *  Plugin Author [YMC](https://wordpress.org/support/users/wssoffice21/)
 * (@wssoffice21)
 * [2 weeks, 2 days ago](https://wordpress.org/support/topic/get-global-js-filter-function/#post-18997648)
 * Good luck!
 *  Thread Starter [fredericv](https://wordpress.org/support/users/fredericv/)
 * (@fredericv)
 * [1 week, 3 days ago](https://wordpress.org/support/topic/get-global-js-filter-function/#post-19002382)
 * Hello,
 * I reopen this thread for a relative question to my 1st question : I have a lot
   of pages to build based on the question above. It’s a shame to make a lot of 
   filters simply with a different parameter, the default term option that you mentionned.
   So is there a way to pass this parameter, default term option, for example within
   the shortcode that displays the filter ? Or another solution ?
 * Many thanks !
 *  Plugin Author [YMC](https://wordpress.org/support/users/wssoffice21/)
 * (@wssoffice21)
 * [1 week, 3 days ago](https://wordpress.org/support/topic/get-global-js-filter-function/#post-19002797)
 * Hi!
 * Yes, you can use the same filter to display different posts based on different
   criteria (tags). To do this, you’ll need to use a programmatic approach. If you’re
   familiar with JavaScript, you should use the plugin API. Here’s a link to the
   documentation: Global Object API
   [https://github.com/YMC-22/YMC-Filter#ymcfiltergrid-global-object-api](https://github.com/YMC-22/YMC-Filter#ymcfiltergrid-global-object-api)
   To do this, you need to enable this option in the plugin’s settings. This is 
   a powerful tool that allows you to control the output using various post selection
   criteria. One way is to pass the tag ID via a link (URL) and then retrieve it
   on the desired page by passing it to the corresponding plugin hooks.
    -  This reply was modified 1 week, 3 days ago by [YMC](https://wordpress.org/support/users/wssoffice21/).
 *  Thread Starter [fredericv](https://wordpress.org/support/users/fredericv/)
 * (@fredericv)
 * [1 week, 2 days ago](https://wordpress.org/support/topic/get-global-js-filter-function/#post-19003337)
 * Hi
 * Yes, it sounds so good to me, I’m familiar with JS, it seems to be the right 
   way to achieve exactly what I want ! Many thanks !
 *  Thread Starter [fredericv](https://wordpress.org/support/users/fredericv/)
 * (@fredericv)
 * [1 week, 2 days ago](https://wordpress.org/support/topic/get-global-js-filter-function/#post-19003427)
 * Hi
 * So, I’m able to interact with the filter by JS (filter by term …etc). I want 
   to use setParams on posts_per_page to display different number of posts depending
   on my pages. But it doesn’t work. Others setParams works (I tried paged, search…
   etc), but not posts_per_page. I don’t use any extra “Advanced query” like callbacks
   for example. So I don’t understand why this parameter doesn’t work. Have you 
   an idea ?
 * Many thanks !
    -  This reply was modified 1 week, 2 days ago by [fredericv](https://wordpress.org/support/users/fredericv/).
 *  Plugin Author [YMC](https://wordpress.org/support/users/wssoffice21/)
 * (@wssoffice21)
 * [1 week, 2 days ago](https://wordpress.org/support/topic/get-global-js-filter-function/#post-19003476)
 * The posts_per_page parameter will only need to be overridden via the Colback 
   function. All available parameters that can be overridden are listed in the plugin
   documentation. For everything else, you’ll need to use the Colback function for
   the filter.
 *  Thread Starter [fredericv](https://wordpress.org/support/users/fredericv/)
 * (@fredericv)
 * [1 week, 2 days ago](https://wordpress.org/support/topic/get-global-js-filter-function/#post-19003509)
 * Okay, thanks.
   But then, why does the `setParams` parameter exist for `posts_per_page`
   in the API?
 * Because one of my main goals is to display a single filter, adjusting the number
   of posts displayed based on the page…
    -  This reply was modified 1 week, 2 days ago by [fredericv](https://wordpress.org/support/users/fredericv/).
 *  Plugin Author [YMC](https://wordpress.org/support/users/wssoffice21/)
 * (@wssoffice21)
 * [1 week, 2 days ago](https://wordpress.org/support/topic/get-global-js-filter-function/#post-19003540)
 * You can use the YMCFilterGrid.setParams(params, options = {}) parameter in your
   scripts. Learn all the settings and parameters for this method in the documentation.
 *  Thread Starter [fredericv](https://wordpress.org/support/users/fredericv/)
 * (@fredericv)
 * [1 week, 2 days ago](https://wordpress.org/support/topic/get-global-js-filter-function/#post-19003556)
 * Sorry, I must have misunderstood your last reply…
   I’m just trying to use the 
   YMCFilterGrid.setParams({ posts_per_page: 12 }) parameter as shown [here](https://github.com/YMC-22/YMC-Filter#ymcfiltergrid-global-object-api).
   But the number of posts displayed doesn’t change.Based on your reply, I understood
   that this setting can only be changed within a callback. Is that correct?
 *  Plugin Author [YMC](https://wordpress.org/support/users/wssoffice21/)
 * (@wssoffice21)
 * [1 week, 2 days ago](https://wordpress.org/support/topic/get-global-js-filter-function/#post-19003614)
 * If you need to change the number of posts displayed in the grid, use this code:
   example:
 *     ```wp-block-code
       const grid1 = YMCFilterGrid.create('#ymc-filter-1');grid1.setParams({ per_page: 2 });
       ```
   
    -  This reply was modified 1 week, 2 days ago by [YMC](https://wordpress.org/support/users/wssoffice21/).
    -  This reply was modified 1 week, 2 days ago by [YMC](https://wordpress.org/support/users/wssoffice21/).
 *  Thread Starter [fredericv](https://wordpress.org/support/users/fredericv/)
 * (@fredericv)
 * [1 week, 2 days ago](https://wordpress.org/support/topic/get-global-js-filter-function/#post-19003657)
 * Ahhhhh ok !!! The param “per_page” works perfectly !
 * Maybe the documentation needs to be updated, because it says YMCFilterGrid.setParams({
   posts_per_page: 12 }), but this setting doesn’t work! YMCFilterGrid.setParams({
   per_page: 12 }) works great 🙂
 * Many thanks !
 *  Plugin Author [YMC](https://wordpress.org/support/users/wssoffice21/)
 * (@wssoffice21)
 * [1 week, 2 days ago](https://wordpress.org/support/topic/get-global-js-filter-function/#post-19003667)
 * Good luck

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

You must be [logged in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fget-global-js-filter-function%2F%3Foutput_format%3Dmd&locale=en_US)
to reply to this topic.

 * ![](https://ps.w.org/ymc-smart-filter/assets/icon-128x128.png?rev=3354891)
 * [YMC Filter](https://wordpress.org/plugins/ymc-smart-filter/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/ymc-smart-filter/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/ymc-smart-filter/)
 * [Active Topics](https://wordpress.org/support/plugin/ymc-smart-filter/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/ymc-smart-filter/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/ymc-smart-filter/reviews/)

## Tags

 * [term](https://wordpress.org/support/topic-tag/term/)

 * 14 replies
 * 2 participants
 * Last reply from: [YMC](https://wordpress.org/support/users/wssoffice21/)
 * Last activity: [1 week, 2 days ago](https://wordpress.org/support/topic/get-global-js-filter-function/#post-19003667)
 * Status: resolved