TitleCase Facets title in Filters with Hook

  • 8 months ago #35485

    Hi, Is there any hook to title case the facets labels, I have some taxonomy with full uppercase. I want to use ucwords php function, but Can you suggest some hook which takes in the label and returns modified label.

    wpsolr
    Keymaster
    8 months ago #35486

    You can use WPSOLR_Events::WPSOLR_FILTER_SEARCH_PAGE_FACET_NAME.

    use wpsolr\core\classes\WPSOLR_Events;
    add_filter( WPSOLR_Events::WPSOLR_FILTER_SEARCH_PAGE_FACET_NAME, ‘get_field_label’, 10, 1 );
    function get_field_label( $custom_field_name ) {
    return ucwords($custom_field_name);
    }

    8 months ago #35487

    Its changing the filter label, I wanted to change the taxonomy terms inside the filter..
    Image image.png of
    The above code is changing the filter headings, like By Category, By Tag..

    wpsolr
    Keymaster
    8 months ago #35488

    You cannot update facet item labels. It would prevent the filters working correctly.

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

You must be logged in to reply to this topic.