• Resolved andrewtayloruk82

    (@andrewtayloruk82)


    Some of my filter values are yes / no, this is fine when presented in a checkbox in the sidebar but when I use the chips it outputs a chip that just says Yes or No. Is it possible to hook into this and change the text it outputs so I can, for example replace the word Yes with perhaps Attribute Name: Value?

    I have to use the chips because I’m using radio buttons for some of the filters and I need a way for people to be able to clear their choices, there’s no standalone reset button so I’m going to rely on the Reset All button in the chips.

    Thanks in advance.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support fesupportteam

    (@fesupportteam)

    Hi @andrewtayloruk82

    For that, you can either modify the chips.php template following the templates overriding – https://filtereverything.pro/resources/templates-overriding/

    Or use the hook “wpc_chips_term_name”, here is s small example how to work with it:

    // Define the callback function for the 'wpc_chips_term_name' filter hook
    function modify_chips_term_name($term_name, $term, $filter) {
    // Modify the term name as desired
    $modified_term_name = 'Modified ' . $term_name;

    // Return the modified term name
    return $modified_term_name;
    }

    // Hook the callback function to the 'wpc_chips_term_name' filter hook
    add_filter('wpc_chips_term_name', 'modify_chips_term_name', 10, 3);

    Best Regards – Victor

    Thread Starter andrewtayloruk82

    (@andrewtayloruk82)

    Thanks, I tweaked the example slightly to support multiple terms.

     // Define the callback function for the 'wpc_chips_term_name' filter hook
    function modify_chips_term_name($term_name, $term, $filter) {
    // Define an associative array with term IDs as keys and modified names as values
    $term_modifications = [
    704 => 'Auto: Yes', // Auto: Yes | replacing value of Yes
    678 => 'Auto: No', // Auto: No | replacing value of No
    ];
    // Check if the current term's ID exists in the modifications array
    if (array_key_exists($term->term_id, $term_modifications)) {
    // Return the modified name for the specific term ID
    return $term_modifications[$term->term_id];
    }
    // Return the original term name if the term ID is not in the modifications array
    return $term_name;
    }
    // Hook the callback function to the 'wpc_chips_term_name' filter hook
    add_filter('wpc_chips_term_name', 'modify_chips_term_name', 10, 3);
Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.