Skip Navigation

[Resolved] Unable to search for custom fields displayed in a View through WordPress search (Relevanssi installed)

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

Problem: I have a View that displays child posts with some of their custom fields. I would like to be able to find those custom fields in a custom text search using Relevanssi, but it doesn't seem to be working.

Solution: Make sure the View's shortcode is placed in the main content editor of the parent post, not in a custom field or other other editor.

This support ticket is created 5 years, 7 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.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 8 replies, has 2 voices.

Last updated by johnC-6 5 years, 7 months ago.

Assisted by: Christian Cox.

Author
Posts
#1245425

I have several custom post types set up using Toolset and have followed the directions on Relevanssi's site here:
hidden link

But search terms within a custom post type are not coming up in results.

For example, I have books (a custom post type) that live on country pages (another custom post type). Books do not have their own pages. When I search by country name, the country shows up in search results, but the country does not show up when I search for a book that is on the country page.

For example, the book "Momo" is on the Germany Books page:
hidden link

If I search for "germany," the Germany Books page shows in search without a problem. But if I search for "Momo," it says no results found:
hidden link

I have shortcodes expanded and have read through several Toolset articles but have not found a solution. I've contacted Relevanssi and they said that there must be a compatibility issue with Toolset or that the shortcodes aren't expanding, even though I have made sure to check the box to do so.

#1245472

Hi, to some degree it depends on how the View you want to index is displayed in the page. For example, if you insert the View in a Content Template that is applied to the custom post type's single post pages, Relevanssi doesn't index those results because they are not directly part of the post's content. Can you tell me more about how the View is displayed on the Germany Books page, for example?

#1245479

I have a CPT and a content template for Countries, which have a relationship with Books. On the Countries content template, there is a view that includes the books related to that country. Is there other info I can provide? Or I can provide backend access.

#1246042

I don't think I need backend access right now. As I was saying, the results of a View will not be indexed if the View is placed in a Content Template assigned to the Country post type. Instead, you can copy + paste the View shortcode into the post body of every Country post in the post type, and remove the View from the Content Template. Then rebuild the index, and the View's contents should be indexed appropriately.

#1252537

I've done that as a test on two countries, rebuilt the index, and still cannot search for the content on the page. Ex:
hidden link You can see the content is duplicated due to to the fact the shortcode is in the content template and on the country CPT itself. But after rebuilding the index, I searched for some words on the page (Berlin noir, Bernie Gunther, etc.) and they did not show in site search.

#1253079

Okay then it's probably best for me to log in and take a look. Can you provide login credentials in the private reply fields here?

#1254395
Screen Shot 2019-05-30 at 10.21.05 AM.png

Okay I see, my instructions were not clear enough. The shortcode must be placed inside the post's main content editor, not in a custom field. The main content editor was disabled in the post type editor screen (see the screenshot), so I re-enabled it and added the View shortcode in the main post content for this post: hidden link. After that I rebuilt the Relevanssi index, and now when I search, I can see the Germany Books post appear in the search results: hidden link

You must add the View shortcode to each Country post in order for it to be indexed.

#1254693

That did the trick! Thank you so much!

#1254695

My issue is resolved now. Thank you!