Home › Forums › General Issues › How to access ACF field in a custom WordPress Rest API endpoint? › Reply To: How to access ACF field in a custom WordPress Rest API endpoint?
Testing the search queries for keywords unique to the FAQ questions/answers fields return the FAQ page, which I assume means that the plugin is working. If the search query is extending to a repeater field, it’s returning the parent page on which those fields are outputted.
I’m confused on where to go next, and I appreciate your patience.
The code in my original post is in a file called search-route.php. I’m assuming the filter you’re talking about in the article is the following:
/**
* Modify the search query with posts_where
*
* http://codex.wordpress.org/Plugin_API/Filter_Reference/posts_where
*/
function cf_search_where( $where ) {
global $pagenow, $wpdb;
if ( is_search() ) {
$where = preg_replace(
"/\(\s*".$wpdb->posts.".post_title\s+LIKE\s*(\'[^\']+\')\s*\)/",
"(".$wpdb->posts.".post_title LIKE $1) OR (".$wpdb->postmeta.".meta_value LIKE $1)", $where );
}
return $where;
}
add_filter( 'posts_where', 'cf_search_where' );
Am I correct in thinking that this is the function I need to add to my search-route.php?
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.