Forums Forums Search & Filter Pro How to title with the taxonomy name

Tagged: 

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

    Hi,

    How can I give to each taxonomy filter result that is shown as an archive the title of the taxonomy.

    I think on the template I should give the variable to call the taxonomy of the filter but don’t know how to do it.

    Any suppport would be really appreciated.

    Thank you!

    Anonymous
    #220240

    For example with the taxonomy (cities) on filtering and choosing the term “Madrid” showing on title:

    Madrid city

    Hope I was a bit more clear.

    Thank you!

    Trevor
    #220244

    This post might help guide you code your template file:

    https://support.searchandfilter.com/forums/topic/have-external-list-of-selected-filters-which-can-then-be-removed-possible/#post-215649

    Note that, if you are refreshing the results using Ajax, if you want the title to change to reflect the filter changes, the title must be inside the Ajax Container specified in the form.

    Anonymous
    #220250

    Thanks for the response.

    I’ve done that but it doesn’t work:

    <?php
    //grab the active query from our search form
    //replace 1526 with the ID of your search form
    global $searchandfilter;
    $sf_current_query = $searchandfilter->get(3959)->current_query();
    ?>
    <h1 class=”hjobs”><?php echo $sf_current_query; ?> jobs</h1><br>

    What am I doing wrong?

    Thanks!

    Anonymous
    #220252

    Ok got it:

    <?php echo $sf_current_query->get_field_string(“_sft_activities”); ?> jobs

    But it displays like this activities: ski jobs

    How can I remove the “activities:”

    Thanks again for your time!

    Trevor
    #220254

    You would need to use some PHP to extract the string you want (or remove the activities: part.

    Anonymous
    #220260

    Yes,

    I’m trying to figure it out. But all what I try it also removes the term.

    Like, if it is “activity: ski jobs” it ends with “jobs”

    Using this code:

    <?php echo $sf_current_query->get_field_string(“_sft_activities”); ?> jobs

    Thank you in advance!

    Anonymous
    #220262

    This is the other code that I added on the template where it displays the results:

    add_filter( ‘get_the_archive_title’, function ($title) {

    if ( is_category() ) {

    $title = single_cat_title( ”, false );

    } elseif ( is_tag() ) {

    $title = single_tag_title( ”, false );

    } elseif ( is_author() ) {

    $title = ‘<span class=”vcard”>’ . get_the_author() . ‘</span>’ ;

    }

    return $title;

    });

    ?>

    Trevor
    #220266

    You would probably put the string into a variable, get the string length of the variable (using PHP strlen), then use the PHP substr function by starting at the 13th character?

    Anonymous
    #234630
    This reply has been marked as private.
Viewing 10 posts - 1 through 10 (of 10 total)