Forums Forums Search & Filter Pro using string to translate text in within filter

Viewing 10 posts - 11 through 20 (of 26 total)
  • Trevor
    #214453

    Co authors plus is a plugin that allows more than one author of a post. That paricualr author needed to add more authors to the list. It would not be relevant to you, except to, as all snippets may, offer some ideas. In your case, you are not trying to delete an option, merely to change its label.

    Anonymous
    #214455

    Hello is there a particular post that cant help me with this. I am looking at all the php and I have not an idea which I need to get it to swap out text in the labels of the filter.

    Anonymous
    #214457

    I have found this however it as sfid ==12345 what do you use to replace 12345? Would this be a more correct snippet.

    function my_plugin_search_filter_change_label($input_object, $sfid) {
      if ($sfid == 12345 && $input_object['name'] == '_sf_post_type') {
        foreach ($input_object['options'] as $key => $option) {
          if ($option->label == 'Media') {
            $input_object['options'][$key]->label = 'Photos';
          }
        }
      }
      return $input_object;
    }
    add_filter('sf_input_object_pre', 'my_plugin_search_filter_change_label', 10, 2);
    Trevor
    #214465

    12345 is the ID number of the form.

    Anonymous
    #214467

    Okay thanks where would I put this code, could I use it in the archive-downloads_french.php post type theme or does it go somewhere else?

    Trevor
    #214477

    It would normally go in the child theme functions.php file.

    Anonymous
    #214482

    I have tried it in the functions.php but I cant seem to get it to change word ‘Brochures’ to ‘Test’

    This is the code I have used am I missing something?

    <?php
    function my_plugin_search_filter_change_label($input_object, $sfid) {
      if ($sfid == 845 && $input_object['name'] == '_sft_file_type[]') {
        foreach ($input_object['options'] as $key => $option) {
          if ($option->label == 'Brochures') {
            $input_object['options'][$key]->label = 'Test';
          }
        }
      }
      return $input_object;
    }
    add_filter('sf_input_object_pre', 'my_plugin_search_filter_change_label', 10, 2);
    ?>
    Trevor
    #214489
    This reply has been marked as private.
    Anonymous
    #214510

    Thankyou

    Ross Moderator
    #214522

    Hi there

    What happens when you echo something inside each if statement?

      if ($sfid == 845 && $input_object['name'] == '_sft_file_type[]') {
       echo "got here";

    And

      if ($option->label == 'Brochures') {
            echo "got in the brochures option";

    Do you see them on the front end?

    I think also your field name is probably _sft_file_type not _sft_file_type[]

    Thanks

Viewing 10 posts - 11 through 20 (of 26 total)