• Resolved danielpenalverramila

    (@danielpenalverramila)


    Hi team,

    I would like to know if there is some way to filter a custom WP_QUERY results. I have a custom product searcher based on several atributes and some database extra tables and I get bunch of product ID’s. Then I’m doing a custom WP_QUERY with ‘post__in’ parameter filled with the products ID’s.

    I would like to know if there is some way to have my filters available so they only show available filters for the result ID’s and they work as a natural archive into Woocommerce with ‘have_post()’ function.

    I’m able to change my method to adapt it to diferent procedure if it’s necessary but for sure I need those post ID’s only to be displayed.

    Is there any way to archive this?

    Thank you in advance

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter danielpenalverramila

    (@danielpenalverramila)

    Post Update: I could modify the main woocommerce product archive WP_QUERY with the ‘pre_get_posts‘ filter and show the custom product searcher results as desired.

    Filters WORK as expected & desired! 🙌🏽</img>

    BUT they show all attributes available to be selected (without the searcher criteria applied). That’s not the functionality I desire, I would prefer to show only the available attributes considering the WP_QUERY filter I’ve made.

    So I understand there is a filter somewhere where you do your own query and do not use the main one, maybe? How can I modify this query and align it with my pre_get_post filter?

    Plugin Author RazyRx

    (@razyrx)

    Hello,

    Plugin use hook woocommerce_product_query to get default WooCommerce query, it seems pre_get_posts triggered later and plugin do not use this changes.

    You can also try to use woocommerce_product_query hook to change query.

    Regards,
    Oleg

    Thread Starter danielpenalverramila

    (@danielpenalverramila)

    Hi Oleg,

    This worked like a charm! Using ‘woocommerce_product_query’ made filters became integrated with the custom query. Really usefull and fast support, thank you very much!

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

The topic ‘Filtering a custom query (WP_QUERY)’ is closed to new replies.