• matheuskps

    (@matheuskps)


    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://www.ads-software.com/plugins/ajax-load-more/

Viewing 10 replies - 1 through 10 (of 10 total)
  • Thread Starter matheuskps

    (@matheuskps)

    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

    (@dcooney)

    Hi,
    Can you please post your shortcode? It might help me understand the issue better.
    Cheers,

    Thread Starter matheuskps

    (@matheuskps)

    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

    (@matheuskps)

    meta value is dinamically, like search term.

    I would like to search for terms and custom fields, you understand?

    Thread Starter matheuskps

    (@matheuskps)

    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

    (@dcooney)

    Have you confirmed that $term is a value?

    Thread Starter matheuskps

    (@matheuskps)

    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

    (@dcooney)

    Well that means the search is returning zero results.

    Why are you searching for the same term as the meta value?

    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

    (@dcooney)

    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.