Forums Forums Search & Filter Pro Display custom field in results

Tagged: 

Viewing 10 posts - 1 through 10 (of 10 total)
  • Anonymous
    #15837

    I’m sure this is very simple. All I need to do is to display a custom field (price) in the search results page….The custom fields was produced using Advanced Custom Fields.

    Could someone please point me in the right direction…?

    Anonymous
    #15841

    OK,
    I followed the instructions here so I could modify the results.php file.

    However, it seems that the results page on the website is still not using the results.php template. I know, as I deleted all the content from the file, uploaded it to the newly-created search-filter folder and nothing changed.

    You can test out the search here gotimetrekkers.com to see

    I’m sure there’s something simple I’m doing wrong.

    Any ideas?

    Anonymous
    #15842
    Anonymous
    #15849

    OK…progress.

    So, (for me anyway), if you use shortcode method make sure that all the fields in the ‘As archive’ are empty. Only when these were empty will it use the results.php (at least in my case)

    Ross Moderator
    #16447

    Hey there, have you got this working now?

    Thanks

    Anonymous
    #16470

    Yes seems to be ok now.
    Cheers

    Anonymous
    #34780

    Hello,

    How did you manage to show the result page if i may ask? Because i can’t get it to work. I’m using advanced custom fields for displaying the custom fields and using Woocommerce for the shop.

    I added a customfield on the category page of Woocommerce. Which can be filled in when editing or adding a category in the backend.

    I got it to work to display a custom field on the category page of Woocommerce using this:

    <?php
    $queried_object = get_queried_object();
    $taxonomy = $queried_object->taxonomy;
    $term_id = $queried_object->term_id;
    the_field(‘title_informatie_over_categorie’, $taxonomy . ‘_’ . $term_id);
    ?>

    But that doesn’t work for the results from Search & filter pro.

    Hope to hear from you.

    Best regards,
    Laurens

    Ross Moderator
    #34798

    Hi Laurens

    The issue I think here is that when using taxonomies, S&F doesn’t actually use a taxonomy query (it uses its own internal query).

    So the get_queried_object will not contain the taxonomy information you might expect.

    To get around this S&F has its own method for accessing the query data which should help:

    http://www.designsandcode.com/documentation/search-filter-pro/accessing-search-data/

    Thanks

    Anonymous
    #34854

    Hey Ross,

    Thanks for your response
    . I having kinda trouble getting a Advanced customfield displayed on the (results) category page.

    On the normal category page of woocommerce the advanced customfield is displayed correctly. But when i start filtering it doesn’t work.

    I used some info from the page you posted above. But no results.

    Do you maybe have an example? Maybe someone that asked the same question. I couldn’t find it on the forum.

    Ross Moderator
    #34897

    Hey Laurens, its not something I’ve come across before, I’ll try to do a quick test again with ACF, but as far as I knew it was working ok.

    From what I can see it looks like you are using the_field incorrectly:

    http://www.advancedcustomfields.com/resources/the_field/

    It says the second argument should be left blank, OR, the post ID passed.

    the_field(‘title_informatie_over_categorie’, $taxonomy . ‘_’ . $term_id);

    You are passing $taxonomy . ‘_’ . $term_id – this is not hte post ID, so leave this argument out altogether or pass the ID of the current post.

    Also, I saw a shortcode to get the same info, have you also tried this?
    http://www.advancedcustomfields.com/resources/displaying-custom-field-values-in-your-theme/

    Thanks

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