Displaying posts' ACF fields in results
markusParticipant2 years, 7 months ago #21546
I wonder how I set what posts’ ACF fields are returned by the query.
I managed to define those fields in add_fields function in class-wpsolr-abstractsearchclient.php, and then they are used by get_results_results function in the same file. Is that the way – should I really edit those core functions? I wonder if I miss something important.markusParticipant2 years, 7 months ago #21610
Thank you for your reply.
I assume this stands for showing results in a separate search page. How about displaying real-time search suggestions results? Does the same method apply when displaying result posts’ values (ACF fields) in suggestions? I tried to use that function in the WPSolr twig template (__theme_dir__/wpsolr-templates/twig/suggestions) but it didn’t seem to work.
Alternatively, if it doesn’t work other way and I have to modify those plugin’s core files, can I somehow override them by my child theme?wpsolrKeymaster2 years, 7 months ago #21617
When you’re configuring your suggestions in WPSOLR, there is a “Download and install this example child theme” link. The download zip file contains a full example of a child theme functions.php customizing both the suggestion template twig file and the data used by the twig template.
Use ACF get_field() to add your ACF fields to the data, and modify the twig template to display the fields.
You must be logged in to reply to this topic.