WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce - excelling eCommerce
Remove the word "The" in sort/order alphabetically (3 posts)

  1. mjb709
    Member
    Posted 1 year ago #

    Hi everyone,
    I'm looking to remove the word "The" in my product sort/order when arranging alphabetically. I think a hook or filter that would remove the word "The" when it's the first word would work.

    For example, I have a product called "The Smiths" and I want it to be in the S section and not the T section since people would look in the S section.

    Has anyone done this or know of anyone who has done this customization? It seems like it would be a pretty helpful addition to WooCommerce as a standard feature.

    Thanks

    http://wordpress.org/extend/plugins/woocommerce/

  2. bheadrick
    Member
    Posted 1 year ago #

    this should do it:

    add_filter('posts_orderby', 'edit_posts_orderby');
    function edit_posts_orderby($orderby_statement) {
    	$orderby_statement =
    str_replace('title','replace(title,"the ","")');
    	return $orderby_statement;
    }
  3. KaitlinFNF
    Member
    Posted 10 months ago #

    This code seemed to work beautifully, but then I noticed as I was adding products that some of them were just going to the bottom of the list and were no longer sorting alphabetically. I was troubleshooting and took the code away and they all magically resorted themselves alphabetically, but when I put the code back in they go wonky again.

    Any idea why that would be? Is there a fix?

    Thanks!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic