My problem is this, I have a post_type in the name of "collections" and inside it multiple posts with custom fields "situation-of-freck" and "collection of freckles". The result of these two fields are numbers, to make it easier to sort. I got help to sort these custom fields through a javascript, as in the code below, and it works perfectly. However, I also need that within this order the posts are also sorted by date of publication. In Firefox this order is correct, but in Chrome and IE, the order by date (default wordpress, by the way), does not work. I know it's the javascript that may be messing them up, but I do not know how to fix ... Here is the link that is happening: link
<ol id="pecas">
<?php $args = array( 'post_type' => 'colecoes');
$wp_query = new WP_Query($args);
if ( have_posts() ) : while ( have_posts() ) : the_post();?>
<li class="foto" data-char="<?php if( get_field('situacao-da-peca') == '1' ):?>c<?php the_field('colecao-da-peca');?><?php endif;?><?php if( get_field('situacao-da-peca') == '2' ):?>b<?php the_field('colecao-da-peca');?><?php endif;?><?php if( get_field('situacao-da-peca') == '3' ):?>a<?php the_field('colecao-da-peca');?><?php endif;?>">
<div class="imagem"></div>
</li>
<?php endwhile; endif;?>
</ol>
<script>
$("#pecas li").sort(sort_li).appendTo('#pecas');
function sort_li(a, b){
var r = /[a-z]/;
var aD = $(a).data('char');
var bD = $(b).data('char');
var va = aD.charCodeAt(0);
var vb = bD.charCodeAt(0);
if(va == vb){
var aN = parseInt(aD.replace(r, ''));
var bN = parseInt(bD.replace(r, ''));
return bN > aN ? 1 : -1;
}
return vb > va ? 1 : -1;
}
</script>