How do i add acf fields to search result

Posted in: Newspaper
Post count: 24

I would like to have ACF field values to be added to the search result.
I understand that you can not do a lot of customization, so i was searching for myself and i have got this:

https://gist.github.com/charleslouis/5924863

and i was adding this to functions.php, but it is not working for me.

Maybe you can help me to get this working. (Newspaper V 6.6.2)

Post count: 9544
Post count: 24

thank you so much!
its working!
but there one part, where its not showing:
the ajax search in the menu bar

maybe you can help me with this…
i guess you have to change something here
wp-content\themes\Newspaper\includes\wp_booster\td_data_source.php

in the block:
static function &get_wp_query_search($search_string) {
$args = array(
‘s’ => $search_string,
‘post_type’ => array(‘post’),
‘posts_per_page’ => 4,
‘post_status’ => ‘publish’
);

$td_query = new WP_Query($args);
return $td_query;
}

Post count: 22421

Hello,

Unfortunately we cannot provide a quick solution for this. The ajax search was designed to work with posts not custom fields. Even if you manage to get it to work with custom post types, ta custom field is not a post type. All of the code has to be changed.
As you can see here: http://screencast.com/t/nOdiP3Bc the result will grab posts, not fields.
You can find the function here:
http://screencast.com/t/StjxCgsUf
You will have to get some hired help on this one as it won’t be so easy like simply copying a piece of code or replacing another piece. This will require the code to be adaptated to the fields code.
You can hire a freelancer form sites like studio.envato.com if you truly need this customization.

Thank you for your understanding.

Post count: 108

But .. if by mistake, you mamage to code this into future updates, that will be just perfect 😉

Post count: 22421

Hi,
I will add this suggestion to our list for future updates and maybe in a future version we will be able to implement it.
Thank you!

Post count: 108

Link that was posted above by Chris contains a code for functions.php, which works just fine and it search also ACF. Well not the AJAX part, but when you press enter all ACF are searched.

Thank you

Viewing 7 posts - 1 through 7 (of 7 total)
The forum ‘Newspaper’ is closed to new topics and replies.