Skip Navigation

[Resolved] Search results not displaying custom post types nested in page

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

Problem: I am using Polylang to translate content on my site. I have a custom post type called Products that includes some custom field values. I have indexed those fields with Relevanssi. I have a View of Products that includes a text search filter, but the Products do not appear in search results.

Solution: Translate Products or recreate them with Polylang translation settings updated.

This support ticket is created 5 years, 10 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 14 replies, has 2 voices.

Last updated by lloydW 5 years, 10 months ago.

Assisted by: Christian Cox.

Author
Posts
#1205567

I am trying to: I have a custom post type (called Products). These are shown within standard WordPress pages, in a table created by the Views plugin. When I search for content in a custom post type (i.e. the post name or other custom fields) it does not appear in the search results.

I have installed Relevanssi and followed the indexing instructions. I have created a custom WordPress Archive to display results - this is working but just not finding the custom post type data. Ideally, it should return the standard WordPess page where the Products are contained.

Link to a page where the issue can be seen: hidden link
Password for access: futuresysceep
Try searching for this term (the custom post title): 920213U000S0201

I expected to see: It should bring up this page as a result (as the custom post type data is contained within it, via Views plugin): hidden link

Instead, I got: It displays no results.

#1205689

Hi, Relevanssi isn't designed to index the results of a View inserted in a custom Page like this. Relevanssi indexes post content like title and body, and can also be configured to index custom fields...but only those elements associated with the current post. In this case, you're trying to search by elements from related posts.

If you want to achieve something similar, you can add the Product post type to the Relevanssi index, then use conditionals in your WordPress Archive to display links to the parent Page instead of the Product. The technique is similar to another ticket, which uses a Repeatable Field Group (RFG) instead of a child post type: https://toolset.com/forums/topic/searching-keywords-from-repeating-field-group-is-not-working/

Let me know if you have questions about this approach.

#1206249

Hi Christian,

Thank you for coming back to me. Yes, this is exactly what I'd like to do.

I believe I have added the Product post type to the Relevanssi index already (although please correct me if I'm wrong!), can you advise how I would use the conditionals to show the parent page of the Product?

Thanks again,
Tom

#1206397

The first step is to get search results to appear in the search archive. Right now, I'm having trouble getting any Product results to appear. Even if I search for the Product title exactly, no results are found:
hidden link

So I temporarily deactivated other plugins to see if there is a conflict, and as soon as I deactivated Polylang, search results began to appear for Products. I noticed that the Product post type is not translated. Is that intentional, or do you plan to translate Products?

#1206985

Thanks again Christian, really appreciate your support on this... getting these search results to appear has been driving me slightly mad...

The plan is to translate Products using Polylang too, although I may be able to work around this with the client if it's going to cause an issue.

#1207163

Hmm, okay I'm not sure how well post relationships will work with Polylang. You may have to establish post relationships separately for each language. WPML handles this internally by establishing the post relationship in the primary language only. Regardless, we can give it a shot. Change the Polylang settings to translate the Product custom post type. Then translate the Products (and their parent Pages) into all languages. Then we can check the search results once more.

#1207194

Thanks Christian. I'm just going to check with the client whether they definitely need the Products translated - assuming it will be easier to fix this bug if they don't?

#1207208

I can't say for sure which is easier to address yet, unfortunately. What I have to do first is evaluate the issue so I can give my 2nd tier team specific instructions about you want to accomplish and the steps you're taking to achieve those goals. Then they can do a deeper investigation to determine if there's a configuration issue, or a bug we need to resolve on our end, or something Polylang needs to resolve on their end, or if a collaboration is necessary. There are several moving parts here so it's important to know exactly what you want to achieve before we go down the wrong path.

#1207417

Ok excellent, I understand. I've just spoken to the client, all the data in Products is universal across all languages so we won't need to translate these custom post types. Hope that helps, and thank you again.

#1207802

Ok thanks. I am escalating this to my 2nd tier team because I was unable to get search results for untranslated post types to appear in my local tests. If I translate the posts with Polylang, then rebuild the Relevanssi index, the problem was resolved. So I'll need some assistance to determine the source of the problem. I'll let you know what I find out.

#1207835

Great stuff, thanks Christian. Really appreciate the support as ever 🙂

#1209471

Okay my 2nd tier team has done some additional investigation and determined that untranslated custom post types do not seem to appear in the Relevanssi search results, even if Toolset is completely deactivated. They were able to add a custom post type using custom code and deactivate Toolset plugins. Even then, untranslated CPTs did not appear in search results. I'm not sure if that's a Polylang bug or a configuration issue, so you may need to ask their support team for assistance.

On the other hand, a more practical solution might be to translate Product posts and rebuild the Relevanssi index. I would give that a shot first, and if it's not working as expected try reaching out to the Polylang team for assistance.

#1210560

That's great, thank you Christian. I'll give the translating of Product posts a try this evening and come back to you.

#1210576

Sure, I'll stand by for an update.

#1210738

Hi Christian, very happy to say I've had a breakthrough here!

I rebuilt the existing Products with Polylang enabled for these custom posts (but didn't translate them) and they're appearing in search results fine now.

hidden link

So my guess is they were 'stuck' in the pre-translate mode before this setting was changed.

The Products don't appear when searched in the other languages unless they've been translated, which actually works better (for example, if the client has a smaller offering in a different country then they could only translate the necessary Products).

Speaking with my client today, they actually prefer the Products appearing individually in search results rather than their parent page, so I've created a simple layout for the Products to accommodate this.

So in a nutshell, all is fixed and working. Thank you again for your support and please pass my best on to the 2nd tier team who helped too.

Tom