I’m trying to order this roster by Jersey Number but haven’t been able to make it work. I’m not a programmer and have searched and tried to make this work multiple times.

Thank you so much for any help.

http://onramp.website/rosters-2017/17u-navy/

Here is the beginning PHP code:

<?php get_header(); ?>

<?php wp_reset_query(); ?>


<?php
$post_name = $post->post_name;

if ($post_name == "17u-navy") {
$post_type = "17u_navy";
}

elseif ($post_name == "15u-navy") {
$post_type = "15u_navy";
}

elseif ($post_name == "17u-red") {
$post_type = "17u_red";
}

elseif ($post_name == "17u-white") {
$post_type = "17u_white";
}

elseif ($post_name == "17u-gold") {
$post_type = "17u_gold";
}

$args = array('post_type'=>$post_type,'posts_per_page'=>-1, 'orderby' => 'number', 'order' => 'ASC',);
$the_query = new WP_Query( $args );
$flag = 0;

if ($the_query->have_posts()):
?>




<?php while ($the_query->have_posts()): $the_query->the_post(); ?>

<?php
$flag++;
?>

<?php if ($flag == 999): ?>

<?php $flag = 0; ?>





<?php endif; ?> 

Read more here: How can I order by a variable in this PHP code?


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: