Using custom fields in suggestions results
- markusParticipant4 years, 7 months ago #21522
Hi,
I have added a few custom fields for pages by using Advanced Custom Fields plugin. I’d like to use them when showing real-time search suggestions results. I can choose the fields to be indexed in the settings (2.2 Data) but how can I show e.g. an icon associated to a specific page in suggestions? I know I can use a twig template to define how suggestions results are displayed but the result data set doesn’t include those custom fields.
Does the ACF extension have to be activated from WPSolr settings (1. Activate extensions)? If I activate it, I can’t choose which fields to search in (2.2. Data).BR
wpsolrKeymaster4 years, 7 months ago #21523Suggestions are showing objects with an archive, like post types and taxonomies. Custom fields do not have an archive, therefore there would be no link to redirect to in the suggestions.
For WooCommerce, attributes are taxonomies, hence they can be show in suggestions.
wpsolrKeymaster4 years, 7 months ago #21547Sorry, I misunderstood your question.
You wanted to display some custom fields inside the results, not showing custom fields as results.
For that, you could use the hook
WPSOLR_Events::WPSOLR_FILTER_SOLR_RESULTS_APPEND_CUSTOM_HTML
, and add a section ‘custom_html’ in your custom twig template, for example:{% if result.custom_html %} {{ result.custom_html }} {% endif %}
You must be logged in to reply to this topic.