I'm running wordpress.
So have a comma separated string of post IDs and need to order found posts by the order which they are listed in the string.
Without sql query I can reach this simply by adding 'orderby' => 'post__in'
in arguments.
But I need to do it via sql query. Here is my SQL query:
$idList = '2,50,10,25,150,1200,356';
$sql = "SELECT * FROM wp_posts WHERE ID IN ($idList)";
Above query return results in growing order, like this: $idList = '2,10,25,50,150,356,1200';
but I need how they are ordered in my string. Didn't find how I can do the same in sql query. Any ideas please?