• Resolved johndoe01

    (@johndoe01)


    Greetings.

    I’m a bit lost on a client’s request. My client wants that i should change the labels of the sorting options of the category view. I meant as in this image…
    https://i.imgur.com/7pplZR4.png
    But for example instead of Newest First change the string for Most Recent, Oldest First for Oldest, and so on.

    Since i have 3 instances based on adverts_list shortcode (To clarify i managed to do 2 more clones of the adverts list with some variations on visual layout). On those instances I can change the strings of the lines:

    
    // options: title, post_date, adverts_price
        $sort_options = apply_filters( "adverts_list_sort_options", array(
            "date" => array(
                "label" => __("Publish Date", "wpadverts"),
                "items" => array(
                    "date-desc" => __("Newest First", "wpadverts"),
                    "date-asc" => __("Oldest First", "wpadverts")
                )
            ),
            "price" => array(
                "label" => __("Price", "wpadverts"),
                "items" => array(
                    "price-asc" => __("Cheapest First", "wpadverts"),
                    "price-desc" => __("Most Expensive First", "wpadverts")
                )
            ),
            "title" => array(
                "label" => __("Title", "wpadverts"),
                "items" => array(
                    "title-asc" => __("From A to Z", "wpadverts"),
                    "title-desc" => __("From Z to A", "wpadverts")
                )
            )
        ) );
    

    But tried on them and the result appeared without changes. I’m not sure how can I change those labels without altering the Core files (which I tried without any obtainable result).

    I’m not sure if through a mod in the functions can do the job but now i’m lost.
    Thanks in advance.

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Greg Winiarski

    (@gwin)

    Hi,
    there are few ways to change the labels, the easiest would be to use a plugin like Say What? and customize the “Newest First” phrase.

    Another option would be to use a adverts_list_sort_options filter to change the labels

    
    add_filter( "adverts_list_sort_options", function( $labels ) {
      $labels["date"]["items"]["date-asc"] = "Most Recent";
      return $labels;
    } );
    

    From your question i am not use if you want to make this change on one of the [adverts_list] only, if so then inside the code snippet you can add something like

    
    if( ! is_page( 100 ) ) {
      return;
    }
    

    where the 100 is actual ID of the page where the labels should be changed.

    Thread Starter johndoe01

    (@johndoe01)

    Thanks for reply.

    Tried with Say What? and i had no results. Used the code and does as I need, even on the variations pages.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Change Sorting Labels’ is closed to new replies.