show custom fields in search results

Discussion in 'GeoCraft WordPress Theme' started by zweitbuch, Mar 19, 2014.

  1. zweitbuch

    zweitbuch Member

    Joined:
    Mar 18, 2014
    Messages:
    172
    Likes Received:
    1
    is it somehow possible to also show custom fields in search results?
     
  2. Gourav

    Gourav Support Staff

    Joined:
    Oct 19, 2012
    Messages:
    7,728
    Likes Received:
    207
  3. zweitbuch

    zweitbuch Member

    Joined:
    Mar 18, 2014
    Messages:
    172
    Likes Received:
    1
    but this link doesnt relate to my question, i was asking that for example if somebody searches for "Marketing" then in the search results right after the search if i can there also have information from my custom field (e.g. adress, price, etc.)
     
  4. Nitesh

    Nitesh Support Staff

    Joined:
    Oct 19, 2012
    Messages:
    5,165
    Likes Received:
    160
    Hello,

    Ok, For it open "template_search.php" file and paste code given below as shown in the image.

    Code:
    <?php if (get_post_meta($q->ID, 'geocraft_timing', true)): ?>
                                        <p class="f_post_meta"><img src="<?php echo TEMPLATEURL . '/images/website.png'; ?>"/>&nbsp;&nbsp;<?php echo get_post_meta($q->ID, 'geocraft_timing', true); ?></p> <?php endif; ?> 
    Add your "HTML variable name" in place of 'geocraft_timing'.
    Check image for reference.

    search.png


    Thanks & Regards
    Nitesh Raghuwanshi
     
  5. zweitbuch

    zweitbuch Member

    Joined:
    Mar 18, 2014
    Messages:
    172
    Likes Received:
    1
    awesome nitesh, that was exactly what i was searching for!!

    could you also tell me the file which i have to adapt when i want to do the same with the entries which are showed at the start page (when there was no search yet??
    and is there a possibility to display one of the custom fields right next to the listing title :)!?
     
  6. zweitbuch

    zweitbuch Member

    Joined:
    Mar 18, 2014
    Messages:
    172
    Likes Received:
    1
    plz help
     
  7. Nitesh

    Nitesh Support Staff

    Joined:
    Oct 19, 2012
    Messages:
    5,165
    Likes Received:
    160
    Hello,

    Code:
    <?php if (get_post_meta($post->ID, 'geocraft_timing', true)): ?>
                                        <p class="f_post_meta"><img src="<?php echo TEMPLATEURL . '/images/website.png'; ?>"/>&nbsp;&nbsp;<?php echo get_post_meta($post->ID, 'geocraft_timing', true); ?></p> <?php endif; ?> 
    For front page add same code in the "front-page.php"

    front.png

    For category page open "loop.php"

    loop.png

    Thanks & Regards
    Nitesh Raghuwanshi
     
  8. zweitbuch

    zweitbuch Member

    Joined:
    Mar 18, 2014
    Messages:
    172
    Likes Received:
    1
    sorry but this doesnt work, and i also just have the file "front-page-hold.php"

    and how can i display one of the custom fields right next to the listing title !?
     
  9. Nitesh

    Nitesh Support Staff

    Joined:
    Oct 19, 2012
    Messages:
    5,165
    Likes Received:
    160
    Go to the
    General settings > Theme options > General settings / front page on/off
    On front page from there and then make changes in the files as posted above.

    I am not getting exactly which field you want to show next to the listing title.
    Please share screenshot with clear instructions. Geocraft is a big theme and i really don't want to give you random solution. It may leave error on your site.

    Thanks & Regards
    Nitesh Raghuwanshi
     

Share This Page