Skip Navigation

[Resolved] Text Search Show Other CPT Result

This thread is resolved. Here is a description of the problem and solution.

Problem:

Relevanssi results show in Toolset with items outside of designated Custom Post Type items

Solution:

There was a conflict with another theme or plugin.

- IMPORTANT STEP! Create a backup of your website.
- Switch to the default theme such as "TwentyTwenty" by going to "WordPress Dashboard > Appearance > themes".
- Go to "WordPress Dashboard > Plugins" and deactivate all plugins except Toolset and Toolset add-ons.
- Check if you can still recreate the issue.
- If not, re-activate your plugins one by one and check the issue each time to find out the plugin that causes the problem.

Relevant Documentation

https://toolset.com/course-lesson/searching-texts-in-custom-fields-with-toolset-and-relevanssi/

This support ticket is created 2 years, 3 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

This topic contains 8 replies, has 3 voices.

Last updated by wilfredC 2 years, 3 months ago.

Assisted by: Christopher Amirian.

Author
Posts
#2486643

I have a page with the list of products, the page shows all products which is correct. However, when I search for something with the text search input, it shows the other CPT's post title.

hidden link

#2486755

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi there

It's not clear what is been showing on the search page or the results page from the front end.

Would it be possible to get access to that site so we can check how this is set up?

Let me mark your next reply as private so that we can get log-in credentials from you—you may want to create a temporary admin user for us to use that you can later delete. And be sure to have a current backup of your site.

What is the other CPT whose titles are being shown?

#2486759

Christopher Amirian
Supporter

Languages: English (English )

Hi there,

Would you please kindly follow the steps below to provide the debug information?

- Go to "WordPress Dashboard > WPML > Support > Debug Information (Link)".
- Copy the Debug Information from there.
- Get back to this chat screen and scroll down.
- Find the "Additional Data" section below. (Check the screenshot below)
- Click on the "Debug Info" item to expand it.
- Paste the debug information into the text area.
- Click the "Send Debug Info" button.

Screenshot:
https://wpml.org/wp-content/uploads/tmp/debug_info_20.png

Also, I want to know if you followed the steps below to create the search functionality:

https://toolset.com/course-lesson/creating-a-custom-search/

The post type is determined by the View settings, it's invariant, when Views constructs the query it takes the value for the post type from the View settings, it doesn't need to be "passed" the post type in any sense.

So if your View is returning results from a different post type that would indicate that something is interfering with the query being created by Views.

You can think of Views as a visual wrapper for the main WordPress WP_Query class which is used (by functions such as get_posts) to retrieve posts from the database.

If I had to guess I would say something is likely using the pre_get_posts hook to modify queries, and it isn't "watertight", it is indiscriminately altering any query rather than targeted queries, so it's affecting the query that Views build when it should have nothing to do with it.

That is why I suggest that you also do the test below and see if it has something to do with the interference I talked about:

- IMPORTANT STEP! Create a backup of your website.
- Switch to the default theme such as "TwentyTwenty" by going to "WordPress Dashboard > Appearance > themes".
- Go to "WordPress Dashboard > Plugins" and deactivate all plugins except Toolset and its add-ons.
- Check if you can still recreate the issue.
- If not, re-activate your plugins one by one and check the issue each time to find out the plugin that causes the problem.

Thanks.

#2487535

Christopher Amirian
Supporter

Languages: English (English )

Hi there,

Would you please test by only selecting the data needed for the views to search in Relevenssy and seeing the result?

Also, I suggest that you check this doc and make sure you set things correctly;y:

https://toolset.com/course-lesson/searching-texts-in-custom-fields-with-toolset-and-relevanssi/

Thanks.

#2487541

Hi,

I tested when only tick the product CPT in the Relevanssi setting, and select product for the view.

The result come out as "No item found"

#2487843

Christopher Amirian
Supporter

Languages: English (English )

Hi there,

I created a new page and a view and it shows ok:

hidden link

Now to add a search, it only supports Text Fields and you need to have the test field assigned to the product in the field group and you need to enable the indexing option.

Please check the documentation here:

https://toolset.com/course-lesson/searching-texts-in-custom-fields-with-toolset-and-relevanssi/#registering-custom-fields

Only after that you can add it to the Relevanssi settings and then it should work

Thanks.

#2488267

No, the issue remains.

As you can see before searching, the list got show Product 5, Product 4, Product 3..., all these are the product name.

When I search for keyword "Product", it should result in those product name, but instead it show the Business name like the "
F&B Demo".

#2488721

Christopher Amirian
Supporter

Languages: English (English )

Hi there,

First if all you need to select the 'Title, body and custom fields' option for that search field according to the documentation:

https://toolset.com/wp-content/uploads/2021/01/selecting-contents-to-search-through-2.png

I did that in the search field and then in the test page. Also I deactivated all plugins exept Toolset ones and Relebanssi and it works ok.

So the issue is another plugin that interfere with the query which you need to find by enableing the plugins one by one.

It does not seem to be an issue of Toolset and relevanssi

Thanks

#2489205

My issue is resolved now. Thank you!

I found out that one of my code snippets is causing the issue. The problem fixed after I turn it off.