I need to sort posts using this loop, is an archive page (pc-archive.php) for a CTP named "PC".
Tried with <?php while ( have_posts('order=desc') ) : the_post(); ?>
but no luck... i must be doing something badly.
then I have tried adding this filter, but i dont get it to work...
function my_custom_archive_order( $vars ) {
if ( !is_admin() && isset($vars['post_type']) && is_post_type_hierarchical($vars['post_type']) ) {
$vars['orderby'] = 'menu_order';
$vars['order'] = 'DESC';
}
return $vars;
}
add_filter( 'request', 'my_custom_archive_order');
this is the loop:
<?php while ( have_posts() ) : the_post(); ?>
<div class="galleryphotos">
<a target="_blank" href="<?php echo types_render_field("pcurl", array("raw" => "true")); ?>">
<img class="pcimagestyle" src="<?php echo types_render_field("pcimage", array("raw" => "true")); ?>">
</a>
<div class="icons"> <a target="_blank" href="<?php echo types_render_field("pcurl", array("raw" => "true")); ?>"
<ul class="pcitems">
<li><?php the_title(); ?> </li>
<li> <?php echo do_shortcode('[types field="pcpubname"][/types]'); ?> </li>
<li> <?php echo do_shortcode('[types field="pcdate" format="d/m/Y"][/types]'); ?></li>
</ul>
</a>
</div>
</div> <?php endwhile; // end of the loop. ?>