Forums Forums Search & Filter Pro Display of title with associated custom taxonomies above search results

Viewing 8 posts - 1 through 8 (of 8 total)
  • Anonymous
    #239102

    Hi, I am using your (terrific) plugin with Elementor Pro. I am having quite a hard time displaying a headline with the chosen custom categories above my search results. I mean: Search results for taxonomy a1, taxonomy a2, taxonomy b and taxonomy c.

    I found your post:
    https://support.searchandfilter.com/forums/topic/results-displayed-results-count-searched-tag-associated-categories/

    and adapted it for my use. It turned out quite well BUT this headline does not change when I select another filter. Can you think of any solution for this?

    My code:

    <?php
      global $searchandfilter;
      $sf_query = $searchandfilter->get(5360)->current_query();
      if ($sf_query->is_filtered()) {
        $sf_current_query = $searchandfilter->get(5360)->current_query()->get_array();
        echo "<b>Onderzoek met betrekking tot ";
        $cat_string = "";
        foreach($sf_current_query['_sft_category']['active_terms'] as $item) {
          $cat_string .= $item['name'] . ", ";
        }
        $starost_string = "";
        foreach($sf_current_query['_sfm_starost']['active_terms'] as $item) {
          $starost_string .= $item['name'] . ", ";
        }
    if (($sf_current_query['_sft_reflex-categorie']['active_terms'][0]['name'])<>"") echo "<p>" . ($sf_current_query['_sft_reflex-categorie']['active_terms'][0]['name']) . "</p>";
    if (($sf_current_query['_sft_vaardigheden-categorie']['active_terms'][0]['name'])<>"") echo "<p>" . ($sf_current_query['_sft_vaardigheden-categorie']['active_terms'][0]['name']) . "</p>";
    if (($sf_current_query['_sft_diagnose-categorie']['active_terms'][0]['name'])<>"") echo "<p>" . ($sf_current_query['_sft_diagnose-categorie']['active_terms'][0]['name']) . "</p>";
    echo "</b>";
    }
    ?>

    My CSS:

    p {
    margin: 0;
    display: inline;
    }

    p:not(:last-child)::after { content: ” & “; }
    p:last-child::after { content: “”; }

    Thank you so much in advance!
    Monique

    Anonymous
    #239103

    BTW I am using Elementor Pro with your plugin Search & Filter – Elementor Extension.
    Display results method is set to Elementor posts / portfolio / Products
    Template Options lead to a page I created to display the search results with your Search en Filter widget on it.

    Trevor
    #239115

    This post (I have made it public so you can see it) might help much better:

    https://support.searchandfilter.com/forums/topic/page-title-for-search-results/page/2/#post-238475

    It is very useful becasue it shows how to code if a field has/can have more than one term set.

    Anonymous
    #240947

    Thank you so much for your answer Trevor! I managed to implement the code, but it still does not change when I change the search term through Search & Filter…..

    Hope it is possible, that someone managed to do this?

    Anonymous
    #240953

    The terms do update when I do a complete page refresh. So it should probably be possible….

    Trevor
    #240959

    The code must be INSIDE the Ajax Container on the page for Ajax refresh changes to reflect in the titles. So, either move the code into that container, or choose a container that is a parent that does contain the code.

    That might prove difficult though.

    Anonymous
    #241006

    Found a solution; I turned Ajax off and after that it worked! Thank you so much Trevor!

    Trevor
    #241020

    Thanks for letting me know. I will close this thread for now.

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