The Grid "sort by" problem

Hi,

I’m not sure if you are also responsible for the The Grid plugin or if I have to ask somewhere else.

I recently added a sort by to the grid but since the words were in English I tried to change them in the the-grid.min.js file, thinking that way I could change the names in the frontend too. Unfortunately, now they don’t sort correctly anymore. I changed it back but I’m not sure if I did it correctly. It still does not sort the content correctly. This is the part where I made changes:

ajax",sortData:{excerpt:“p”,title:function(t){return jQuery(t).data(“title”)},id:function(t){return jQuery(t).data(“id”)},date:function(t){return jQuery(t).data(“date”)},author:function(t){return jQuery(t).data(“author”)},comment:function(t){return jQuery(t).data(“comment”)},popular_post:function(t){return jQuery(t).data(“popular-post”)},total_sales:function(t){return jQuery(t).data(“total-sales”)},regular_price:function(t){return jQuery(t).data(“regular-price”)},sale_price:function(t){return jQuery(t).data(“sale-price”)},featured:function(t){return jQuery(t).data(“featured”)},stock:function(t){return jQuery(t).data(“stock”)},sku:function(t){return jQuery(t).data(“sku”)}},defaults:{style:“grid”,layout:“vertical”,fitrows:!1,fullWidth:null,fullHeight:null,rtl:!0,filterComb:!

I changed date to Datum, popular-post to Beliebtheit and title to Titel. I changed it back, but as I said it doesn’t work.

Here is the URL: https://soundtrackz.de/filme

Can you help me with that?

Thanks in advance.

Dennis

Hi @Kilik91,

Thanks for writing in.

Try to reinstall your The Grid plugin to restore the configuration of the plugin. If still not working well, please try to check for plugin conflicts.
Deactivate one by one the plugin so that you could know which is causing it.

Don’t forget to clear cache before doing anything, Let us know how it goes.

Thanks.

Hi Nico,

it worked! Thank you.

Do you know if there is a way to change the sort by names? I would like to translate them to German.

Thanks in advance.

Best wishes,
Dennis

Hi Dennis,

To translate it, you can add the code below in your child theme’s functions.php file

add_filter( 'gettext', 'translate_sort_title', 20, 3 );

function translate_sort_title( $translated_text, $text, $domain ) {


        switch ( $translated_text ) {

            case 'Date' :

                $translated_text = __( 'Datum', '__x__' );
                break;

            case 'Title' :

                $translated_text = __( 'Titel', '__x__' );
                break;
                
            case 'Popular post' :

                $translated_text = __( 'Bekannter Beitrag', '__x__' );
                break;
        }

   

    return $translated_text;
}

Hope that helps.

Hi Paul,

thank you for your reply.

I didn’t quite work though. I’m not sure what I did wrong. After I added the code to the funtions.php the website didn’t load and just gave me the following error message:

Parse error: syntax error, unexpected end of file in /homepages/10/d709417352/htdocs/clickandbuilds/WordPress/MyCMS2/wp-content/themes/x-child/functions.php on line 47

Here is everything that’s in the file, including the code you gave me:

 <?php

 // =============================================================================
 // FUNCTIONS.PHP
 // -----------------------------------------------------------------------------
 // Overwrite or add your own custom functions to X in this file.
 // =============================================================================

 // =============================================================================
 // TABLE OF CONTENTS
 // -----------------------------------------------------------------------------
 //   01. Enqueue Parent Stylesheet
 //   02. Additional Functions
 // =============================================================================

 // Enqueue Parent Stylesheet
 // =============================================================================
 add_filter( 'x_enqueue_parent_stylesheet', '__return_true' );

 add_filter( 'gettext', 'translate_sort_title', 20, 3 );

 function translate_sort_title( $translated_text, $text, $domain ) {


         switch ( $translated_text ) {

             case 'Date' :

                 $translated_text = __( 'Datum', '__x__' );
                 break;

             case 'Title' :

                 $translated_text = __( 'Titel', '__x__' );
                 break;
                 
             case 'Popular post' :

                 $translated_text = __( 'Beliebtheit', '__x__' );
                 break;
         }

 // Additional Functions
 // =============================================================================

Did I write it in the wrong line?

Hi,

You missed the last part.

The entire code should look like this

<?php

// =============================================================================
// FUNCTIONS.PHP
// -----------------------------------------------------------------------------
// Overwrite or add your own custom functions to X in this file.
// =============================================================================

// =============================================================================
// TABLE OF CONTENTS
// -----------------------------------------------------------------------------
//   01. Enqueue Parent Stylesheet
//   02. Additional Functions
// =============================================================================

// Enqueue Parent Stylesheet
// =============================================================================

add_filter( 'x_enqueue_parent_stylesheet', '__return_true' );


// Additional Functions
// =============================================================================

add_filter( 'gettext', 'translate_sort_title', 20, 3 );

function translate_sort_title( $translated_text, $text, $domain ) {


        switch ( $translated_text ) {

            case 'Date' :

                $translated_text = __( 'Datum', '__x__' );
                break;

            case 'Title' :

                $translated_text = __( 'Titel', '__x__' );
                break;
                
            case 'Popular post' :

                $translated_text = __( 'Bekannter Beitrag', '__x__' );
                break;
        }

   

    return $translated_text;
}

Thanks

It worked! Thank you very much!

You’re welcome!
We’re glad we were able to help you out.

I’m want the Grid to be full-width on mobile, but it doesn’t have an option only for mobile or at least I can’t find it. Could you tell me how to enable full-width only on mobile? Starting at 767px.

Thanks in advance.

Dennis

Hi There,

Please add this custom CSS:

@media (max-width: 767px){
    .el2.x-container.max.width {
        max-width: 100%;
        width: 100%;
    }
}

Let us know how it goes!

It worked well, thank you!!

You’re welcome.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.