Okay
  Public Ticket #3645073
Search bar
Closed

Comments

  •  40
    ep started the conversation

    Hi, I am using the theme's search bar. Is there a way to change the placeholder "search site..." text (or is installing Loco Translate the only way?)

  •  1,558
    Laborator replied

    Hi there,

    This string is registered in a .PO file for multilingual purposes so it can be translated, so any plugin which checks the strings of .PO files inside the theme and can change/replace them could work, but we mostly recommend Loco Translate. Manually changing the string is not possible and not recommended.

    Best regards,
    Laborator Team


      Documentation         Join Kalium Users Group

  •  40
    ep replied

    Understood thank you.

    What are the steps in Loco? Do I edit template of theme or add new language in child?

  •  1,558
    Laborator replied

    Hi again,

    To translate or rename theme strings, you can do this via Loco Translate plugin. If you don't have it, please install and activate the plugin on your WordPress site.

    1. Then go to Loco Translate > Manage Translations
    2. Click "New Language" for the currently active theme (if you didn't created it yet, otherwise ignore this step). On the new language page, choose these options – Screenshot
    3. After that, you will be redirected to the editing screen for theme translations. Before you continue with your translations make sure the current language of your site is selected – Screenshot
    4. Follow these instructions to learn how to translate strings – Screenshot
    5. The changes will be applied immediately – Screenshot

    Note: Translation files will be saved to wp-content/themes/{theme-name}/languages folder or global directory of theme translations: wp-content/languages/themes/ (based on your choice). 

    If you have saved your translations inside the theme folder, always save a backup of languages/ folder (inside the theme) when there is a new theme update. After you update the theme (languages folder will be replaced with an empty folder), just move the backup files you previously saved to the same languages directory and your changes will still be applied.

    Best regards,
    Laborator Team


      Documentation         Join Kalium Users Group

  •  40
    ep replied

    Thanks so much Art, all clear!

    One more question – and maybe it is too much customisation but I ask anyway – I need the search bar to be able to search product category and tags. Is there a line of code you could share with me to achieve this? Currently I know it can search words in the product name and description. Or if you could consider for the next theme update.

    Appreciate your help very much. Have a great day

  •  1,558
    Laborator replied

    Hi again,

    By default, WordPress does not include product categories and tags in its search functionality. The standard search only covers product titles and descriptions. However, there are ways to extend this functionality to include product categories and tags such as using 3rd party plugins, some of them are:

    • Relevanssi
    • SearchWP
    • WooCommerce Product Search

    But they have not been tested by us so I am not sure if they work properly with Kalium.

    Another way is by adding a custom code to the functions.php file of the child theme:

    function custom_search_query( $query ) {
        if ( ! is_admin() && $query->is_search && $query->is_main_query() ) {
            // Include product post type
            $query->set( 'post_type', 'product' );
            // Include product categories and tags in the search
            $tax_query = array(
                'relation' => 'OR',
                array(
                    'taxonomy' => 'product_cat',
                    'field'    => 'name',
                    'terms'    => $query->query_vars['s'],
                    'operator' => 'LIKE',
                ),
                array(
                    'taxonomy' => 'product_tag',
                    'field'    => 'name',
                    'terms'    => $query->query_vars['s'],
                    'operator' => 'LIKE',
                ),
            );
            $query->set( 'tax_query', $tax_query );
        }
    }
    add_action( 'pre_get_posts', 'custom_search_query' ); 

    I am not sure if this works, by doing a little research I found it so I hope it works out for you.

    Best regards,
    Laborator Team


      Documentation         Join Kalium Users Group