YMC-22 / smart-filter

YMC Smart Filter, allows to solve a variety of tasks for displaying posts on site pages. For advanced developers, there is an opportunity to independently develop layouts for filters and post cards, which makes the plugin universal.
14 stars 6 forks source link

Search does not work, when providing custom Advanced Query #15

Closed tpapaz closed 6 months ago

tpapaz commented 6 months ago

Hello and many thanks for one of the best plugins for WP!

Currently we have an issue, when we use the following Custom Query:

post_type=person&
posts_per_page=-1&
post_status=publish&
meta_query[relation]=AND&
meta_query[query_one][key]=person_type&
meta_query[query_two][key]=date_joined&
orderby[query_one]=asc&
orderby[query_two]=ASC

As you can see, we sort the query based on 2 meta fields. the post_type is also a custom post type. The returned posts works flawlessly, but when we try to Search then we get the following error:

{
    "key": "37bddaae47950a950923055d889403ad",
    "type": "warning",
    "message": "Undefined array key \"terms\"",
    "file": "wp-content/plugins/ymc-smart-filter/includes/core/frontend/Get_Posts.php",
    "line": 39,
    "stack": [
        "YMC_Smart_Filters\\C\\F\\Get_Posts->get_filter_posts()",
        "do_action('wp_ajax_ymc_get_posts')"
    ],
    "component": "Plugin: ymc-smart-filter"
}
YMC-22 commented 6 months ago

Hi! How do you search? do you use a custom search code or the standard plugin search field? Provide a link to the page of your site where you use the plugin.

tpapaz commented 6 months ago

Using the standard plugin search field. You can see it in action here:


YMC-22 commented 6 months ago

Now it is difficult for us to determine the essence of the problem itself that arises when making a request. Provide us with the custom request settings in the plugin itself (screen or provide access to the admin panel of your site) And also the part of the code where you define the custom request settings in your theme. https://prnt.sc/RMA_fm6bDlz7

tpapaz commented 6 months ago

ok I'll try to be as detailed as possible.

1. Query Options 1 Query-options I haven't set any taxonomies for this post type. Maybe that's the issue?

2. The Advanced Query 2-Query

3. Search options 3-Search

4. Layout Options 4-layout

I load a shortcode, and in functions.php I set a custom grid like the examples:

[ymc_filter id='1711']

function people_custom_post_layout($layout, $post_id, $filter_id, $increment_post, $arrOptions) { ... } add_filter('ymc_post_custom_layout_1711_1', 'people_custom_post_layout', 10, 5); This part is correct.

Thank you for your time and tell me if you need anything else!

YMC-22 commented 6 months ago

Our recommendations: for large and long queries with many different arguments that are passed to the WP_Query object, it is better to use the callback function (2nd option for setting a caste query) See screenshot. See documentation on custom query settings - https://github.com/YMC-22/smart-filter?tab=readme-ov-file#advanced-query Screenshot_1

To correctly configure all parameters, use the official documentation on using the WP_Query object - https://developer.wordpress.org/reference/classes/wp_query/

tpapaz commented 6 months ago

I tried it and it works perfectly! I'm closing the issue.

Thanks!

YMC-22 commented 6 months ago

Good luck!