Forum Replies Created

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

    (@philipsimplynuc)

    Hi,

    I have tried setting the $_GET variable as mentioned above but without any success ??

    Would you believe your suggestion is exactly where my thought process was before I had decided to reach out with you for a second time. Great minds think… ??

    Anyway, thank you very much for your response, I really appreciate it and I now feel really confident in using your plugin long term across our family of websites.

    If you would, please consider adding this feature to the next version of the plugin, I would really appreciate it.
    For the time being, we will just have to accept the count on the secondary widget loops for products is in-correct and not in line with the number of products return by your plugin and its settings.

    It’s a small thing but I’m hoping your next version will fix this for us and I can then amend our widget code to pass ‘58050’ as a $query->query_vars.

    Thanks again

    Great plugin

    Philip C

    Thread Starter philipsimplynuc

    (@philipsimplynuc)

    Sorry just to mention.

    This is just to get the COUNT of products for a search term through your plugin.
    I can code a couple of custom loops and combine the results myself.

    But your plugin is far more efficient using SQL and building using pre_get_posts.

    But how do I ensure WP_QUERY uses your filters.

    I am available for a call via Skype or Zoom if you like to discuss.

    Or if you have any other questions.

    Thanks for your help.

    Great plugin.

    Thread Starter philipsimplynuc

    (@philipsimplynuc)

    Hi,

    Thanks for the reply, and your filter works perfect.
    However, I have another small question for you, if you can help please.

    To demonstrate, please visit the following link:
    https://staging.simplynuc.com/?s=Frost+Canyon&post_type=product&wpessid=58050

    On this page we have searched for products of a particular category. With 11 results found.

    In the sidebar you will now see a custom widget. If you click on “Pages” in the sidebar.
    https://staging.simplynuc.com/?s=Frost%20Canyon&post_type=page

    On this page we have now searched for pages with the same search term.
    Now in the sidebar Products only have 7 results found.

    ————–
    The question I have is, on the second page above.
    This custom sidebar widget uses WP_Query to search for products with the same criteria.
    However, I am only getting 7 results.

    In my widgets code, I have 4 WP_QUERY loops for different post types .etc

    I have used your filter code just before the other post types, which sets ‘disable_wpes’ to TRUE. Which has worked fine and uses the GLOBAL search settings from your plugin.

    However, my question is?
    In the last WP_QUERY in my widget, I need to get the same product count 11 as the main woocommerce page itself. And not 7.

    As I mentioned earlier, I am very familiar with WordPress and coding custom queries.
    And I have attempted to set the ‘disable_wpes’ to FALSE. Just before this last WP_QUERY but I am still only getting 7 results.

    Sorry for the long question, but better to fully explain my question.
    I have tracked down the issue to the filters in your plugin.
    ‘wp_es_custom_query’ & ‘wp_es_pre_get_posts’ NOT being respected for this WP_QUERY

    I assumed that by setting ‘disable_wpes’ back to FALSE.
    That the Woocommerce custom search settings I have setup from your plugin will then be applied.

    So: main_query has run using the URL query_vars & your plugin with custom settings.

    Sidebar Widget:
    1. ‘disable_wpes’, TRUE – Meaning the Global settings from plugin for loops below.

    2. WP_Query for PAGES

    3. WP_Query for POSTS – NEWS

    4. WP_Query for POSTS – BLOG

    5. ‘disable_wpes’, FALSE – Meaning the Custom settings from plugin for loops below.

    6. WP_Query for PRODUCTS

    However, I am only getting 7 results / pre_get_posts NOT building the SQL fully.

    Again any help would be greatly appreciated.

    I have tried setting suppress_filters FALSE
    Declaring a new instance of WPES & WPES_Core and manually calling your functions code.

    `
    add_filter( 'pre_get_posts', function ( $query ) {
        $query->query_vars['s']            = $searched;
        $query->query_vars['post_type']    = 'product';
        $query->query_vars['wpessid']      = 58050;
    }, 999);
    
    $args = array (
        's'                     => $searched,
        'fields'                => 'ids',
        'post_type'             => 'product',
        'post_status'           => $status,
        'posts_per_page'        => -1,
    );
    $query = new WP_Query( $args );
    `

    Kind Regards

    Philip C

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