taxonomy and order of posts
-
I’m running into a problem with my WP site and hoping somebody knows a bit more about PHP then me.
What I’m trying to achieve is changing the ordering of posts. The website https://oahn.ca/networks/small-ruminants/#reportsLink
It is now ordered (from what I can see in the PHP) with the ‘slug’ ordering. But I want all the reports to show in ‘desc’ order by date.
Below is the code I’m editing. I’m just getting started with PHP and after a ton of forums my options running out.<div class="container main"> <?php foreach ( $report_quarters as $report_quarter ) { if ($report_quarter->parent != 0) { if (have_posts($report_quarters)) { echo "<div id='".$report_quarter->slug."-container' class='show-div'>"; } else { } $myposts = get_posts(array( 'numberposts' => -1, 'orderby' => 'post_date', 'order' => 'DESC', 'post_type' => array('reports'), 'post_status' => $post_status, 'tax_query' => array( array( 'taxonomy' => 'network', 'field' => 'slug', 'terms' => array($term->slug) ), array( 'taxonomy' => 'report-quarter', 'field' => 'slug', 'terms' => array($report_quarter->slug) ) )) ); if (empty($myposts)) { //$placeholder = "<div class='col-md-12'><h1>".$report_quarter->name."</h1>No reports available for this quarter.</div><div class='clearfix'></div>"; //echo $placeholder; } else { unset($placeholder); $placeholder = "<div class='col-md-12'><h1>".$report_quarter->name."</h1></div><div class='clearfix'></div>"; echo $placeholder; } foreach ($myposts as $mypost) { global $mypost; $args = array( 'numberposts' => -1, 'order' => 'ASC', 'post_parent' => $mypost->ID, 'post_type' => 'attachment' ); $attachments = get_children( $args ); echo "<div class='col-sm-3 no-padding'> <div class='single-report'> ".apply_filters('the_content', $mypost -> post_content)."</div>"; foreach ($attachments as $attachment) { echo '<a href="' . wp_get_attachment_url( $attachment->ID ) . '" target="_blank" class="report-title">'.$mypost->post_title.'</a></div>'; } } echo "<div class='clearfix'></div>"; echo "</div>"; }} ?>
Viewing 12 replies - 1 through 12 (of 12 total)
Viewing 12 replies - 1 through 12 (of 12 total)
- The topic ‘taxonomy and order of posts’ is closed to new replies.