• I have this code:

    If(empty($_GET["chapter_id"])) {query_posts(array('category__in' => array($category->cat_ID),'posts_per_page'=>-1,'paged'=>$paged, 'orderby'=>'title','order'=>'ASC'));}

    How can i orderby title where title is alphanumeric eg.

    Title 1. New Title
    Title 2. New Title
    Title 10. New Title

    Currently, if i order by title, i get:

    Title 1. New Title
    Title 10. New Title
    Title 2. New Title

    I’ve searched and can’t find a solution.

    [Please post code snippets between backticks or use the code button.]

Viewing 4 replies - 1 through 4 (of 4 total)
  • What is $_GET["chapter_id"] supposed to be testing for?

    Thread Starter a_khan69

    (@a_khan69)

    It checks custom tables for chapter_id received from the url.

    Not sure if it matters though?

    If my understanding of how DBs work is correct, then you can’t do what you want to do in it’s current format. The post_title field is a ‘text’ field, meaning that when it’s sorted it’s sorted alphabetically (that is by order as defined by the character encoding, ‘utf8_general_ci’), so 1000000 will always come before 2.

    You would need to change the format of the data and then sort it using a custom sorting function (quite complicated) to get your desired order.

    Thread Starter a_khan69

    (@a_khan69)

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘how to orderby title (title includes alphanumeric characters)?’ is closed to new replies.