Query posts ordering by title, but ignore ” and special characters

Try this…

$posts = get_posts(
    array(
        "orderby"=> "slug",
        "order" => "ASC",
        "post_type" => "my-custom-post-type",
        "posts_per_page" => -1,
        "fields" => "ids",
        "meta_query" => array(
            array(
                "key" => "ams_park_id",
                "value" => get_the_ID(),
            )
        )
    )
);

Noticed I changed "orderby"=> "title", to "orderby"=> "slug". Typically the slug will be close to the title but all of the special characters will be removed.

Leave a Comment