• Hi There

    I have a collection of products that all follow the same format, namely, EVE{product number}

    I would like to order by product number and have set to order by product title. This works as expected except that when it gets to Eve100 it seems to think that this is EVE10 and then proceeds to list all the products over 100, so the order is broken?

    Would anyone be able to provide advice on what I need to do fix this?

    Many Thanks in Advance for Any Assistance

    Development 14

    • This topic was modified 3 years, 12 months ago by bcworkz. Reason: expand tinyurl

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

Viewing 6 replies - 1 through 6 (of 6 total)
  • Moderator cubecolour

    (@numeeja)

    It sounds like you need to zero pad your product numbers.

    If you have up to 999 products in total all of the numbers should have three digits – so your first product is EVE001, the next EVE002, and so on. Then when you get to EVE099 the following one will be EVE100.

    Thread Starter development14

    (@development14)

    Thank you for the swift reply cubecolour, much appreciated

    Is there anyway around this solution, which would allow me to list the product as eve01 rather eve001?

    Moderator cubecolour

    (@numeeja)

    You could edit just the post slug to add the padding zero, keeping the post titles as they are currently. Then you can specify the orderby parameter to have a value of ‘name’ instead of ‘title’

    Thread Starter development14

    (@development14)

    Thanks again cubecolour

    I’ll work on that tomorrow and will come back if I have any questions

    Enjoy your Sunday

    Moderator bcworkz

    (@bcworkz)

    @development14 – please don’t use URL shorteners like tinyurl in these forums. Bad actors use them to disguise malicious links. To the extent possible, we like to see where links take us. I’m sure you were trying to be helpful. Thanks for the thought but it’s not necessary.

    You could try altering the SQL itself to type cast the title as a numeric value. Use the ‘posts_orderby’ filter to do so. Type casting on a large database can adversely affect performance. Altering the product’s slugs is probably the ideal solution if that doesn’t cause any other adverse effects. If you’ve so many products that manually making the changes would be an onerous task, a custom one-time script could be written to make the changes.

    Thread Starter development14

    (@development14)

    @bcworkz No problem, will send the correct link through on all future posts

    Thanks for the help on this all

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Order By Title Breaks When Get To Number 100 – WordPress Is Treating It Like 10’ is closed to new replies.