Title: Plugin doesn&#8217;t work when I use this code
Last modified: January 14, 2017

---

# Plugin doesn’t work when I use this code

 *  [A](https://wordpress.org/support/users/mrex778/)
 * (@mrex778)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/plugin-doesnt-work-when-i-use-this-code/)
 * Hi
    I’m using this code on my function file to make acf field searchable but 
   when I use it Dw reactions plugin doesn’t work I mean when you vote for a post
   and then when you refresh the page it will be gone
 * [https://ianime.one/anime/sword-art-online](https://ianime.one/anime/sword-art-online)
 *     ```
       <?php
       /**
        * Extend WordPress search to include custom fields
        *
        * http://adambalee.com
        */
   
       /**
        * Join posts and postmeta tables
        *
        * http://codex.wordpress.org/Plugin_API/Filter_Reference/posts_join
        */
       function cf_search_join( $join ) {
           global $wpdb;
   
           if ( is_search() ) {    
               $join .=' LEFT JOIN '.$wpdb->postmeta. ' ON '. $wpdb->posts . '.ID = ' . $wpdb->postmeta . '.post_id ';
           }
   
           return $join;
       }
       add_filter('posts_join', 'cf_search_join' );
   
       /**
        * 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' );
   
       /**
        * Prevent duplicates
        *
        * http://codex.wordpress.org/Plugin_API/Filter_Reference/posts_distinct
        */
       function cf_search_distinct( $where ) {
           global $wpdb;
   
           if ( is_search() ) {
               return "DISTINCT";
           }
   
           return $where;
       }
       add_filter( 'posts_distinct', 'cf_search_distinct' );
       ?>
       ```
   

Viewing 1 replies (of 1 total)

 *  Thread Starter [A](https://wordpress.org/support/users/mrex778/)
 * (@mrex778)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/plugin-doesnt-work-when-i-use-this-code/#post-8655449)
 * ” If everything seems to be okay, then use another browser or incognito tabs “

Viewing 1 replies (of 1 total)

The topic ‘Plugin doesn’t work when I use this code’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/dw-reactions_d2d0cb.svg)
 * [DW Reactions](https://wordpress.org/plugins/dw-reactions/)
 * [Support Threads](https://wordpress.org/support/plugin/dw-reactions/)
 * [Active Topics](https://wordpress.org/support/plugin/dw-reactions/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/dw-reactions/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/dw-reactions/reviews/)

 * 1 reply
 * 1 participant
 * Last reply from: [A](https://wordpress.org/support/users/mrex778/)
 * Last activity: [9 years, 3 months ago](https://wordpress.org/support/topic/plugin-doesnt-work-when-i-use-this-code/#post-8655449)
 * Status: not resolved