Title: Search with custom fields
Last modified: August 22, 2016

---

# Search with custom fields

 *  [matheuskps](https://wordpress.org/support/users/matheuskps/)
 * (@matheuskps)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/search-with-custom-fields/)
 * Hello!
 * I wanna know how I can enable custom fields for the search results, the original
   search only return title and content, not custom fields.
 * I’m using advanced custom fields to create these custom fields.
 * I try use the search query with meta_key and meta_value, but if these parameters
   are together with meta_key and meta_value the search doesn’t work.
 * I need help!
 * [https://wordpress.org/plugins/ajax-load-more/](https://wordpress.org/plugins/ajax-load-more/)

Viewing 10 replies - 1 through 10 (of 10 total)

 *  Thread Starter [matheuskps](https://wordpress.org/support/users/matheuskps/)
 * (@matheuskps)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/search-with-custom-fields/#post-5527759)
 * Sorry, i write something wrong.
 * EDIT:
    I try use the search query with meta_key and meta_value, but if these 
   parameters are together with search parameter, the search doesn’t work.
 *  Plugin Author [Darren Cooney](https://wordpress.org/support/users/dcooney/)
 * (@dcooney)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/search-with-custom-fields/#post-5527909)
 * Hi,
    Can you please post your shortcode? It might help me understand the issue
   better. Cheers,
 *  Thread Starter [matheuskps](https://wordpress.org/support/users/matheuskps/)
 * (@matheuskps)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/search-with-custom-fields/#post-5527925)
 * Hi!
 *     ```
       <?php $term = $_GET['term']; ?>
   
       		<?php echo do_shortcode('[ajax_load_more repeater="repeater5" post_type="produto" posts_per_page="6" meta_key="ref" meta_value="" search="'. $term .'" scroll="false" button_label="Mostrar mais resultados"]'); ?>
       ```
   
 *  Thread Starter [matheuskps](https://wordpress.org/support/users/matheuskps/)
 * (@matheuskps)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/search-with-custom-fields/#post-5527926)
 * meta value is dinamically, like search term.
 * I would like to search for terms and custom fields, you understand?
 *  Thread Starter [matheuskps](https://wordpress.org/support/users/matheuskps/)
 * (@matheuskps)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/search-with-custom-fields/#post-5527927)
 * Works:
 * `<?php echo do_shortcode('[ajax_load_more post_type="produto" posts_per_page="
   6" meta_key="ref" meta_value="999" search="'. $term .'" scroll="false" button_label
   ="Mostrar mais resultados"]'); ?>`
 * Doesnt work:
 * <?php echo do_shortcode(‘[ajax_load_more post_type=”produto” posts_per_page=”
   6″ meta_key=”ref” meta_value=”‘. $term .'” search=”‘. $term .'” scroll=”false”
   button_label=”Mostrar mais resultados”]’); ?>
 * The meta_value should be dinamic.
 *  Plugin Author [Darren Cooney](https://wordpress.org/support/users/dcooney/)
 * (@dcooney)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/search-with-custom-fields/#post-5527928)
 * Have you confirmed that $term is a value?
 *  Thread Starter [matheuskps](https://wordpress.org/support/users/matheuskps/)
 * (@matheuskps)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/search-with-custom-fields/#post-5527930)
 * Yes!
 * if I remove the search = “” of the shortcode , it works .. the post with custom
   field appears , but if I leave the search = ” ” and the meta_key , meta_value
   the same shortcode doesnt work. Not appear any post.
 *  Plugin Author [Darren Cooney](https://wordpress.org/support/users/dcooney/)
 * (@dcooney)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/search-with-custom-fields/#post-5527932)
 * Well that means the search is returning zero results.
 * Why are you searching for the same term as the meta value?
 *  [etcoder](https://wordpress.org/support/users/etcoder/)
 * (@etcoder)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/search-with-custom-fields/#post-5528039)
 * Asking permission to answer the above question.
 * I think we have the same problem.
    Here’s my shortcode
 * `echo do_shortcode('[ajax_load_more post_type="deal" search="'.$searchresult.'"
   meta_key="wpcf-town" meta_value="'.$searchresult.'"]');`
 * The reason why i need to put the same value in search term and meta value is 
   because i need to include the custom field in search result. But unfortunately,
   I can’t do that.
 * Do you have answer for this problem?
 * Thanks in advance.
 *  Plugin Author [Darren Cooney](https://wordpress.org/support/users/dcooney/)
 * (@dcooney)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/search-with-custom-fields/#post-5528040)
 * I just tested and it worked for me.
    My shortcode : `[ajax_load_more post_type
   ="post" meta_key="banner" meta_value="test" search="post"]`
 * The differences are I’m using a standard post type and my search and meta_value
   were not php variables – I don’t think that should matter though.
 * What is the result of `$searchresult` ?

Viewing 10 replies - 1 through 10 (of 10 total)

The topic ‘Search with custom fields’ is closed to new replies.

 * ![](https://ps.w.org/ajax-load-more/assets/icon-256x256.png?rev=2944639)
 * [Ajax Load More – Infinite Scroll, Load More, & Lazy Load](https://wordpress.org/plugins/ajax-load-more/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/ajax-load-more/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/ajax-load-more/)
 * [Active Topics](https://wordpress.org/support/plugin/ajax-load-more/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/ajax-load-more/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/ajax-load-more/reviews/)

 * 10 replies
 * 3 participants
 * Last reply from: [Darren Cooney](https://wordpress.org/support/users/dcooney/)
 * Last activity: [11 years, 5 months ago](https://wordpress.org/support/topic/search-with-custom-fields/#post-5528040)
 * Status: not resolved