I trying to make a pagination links from my website.
Schema:
Serie | (category)
|_ Temporada 1 (taxonomy: temporada)
|_ Episodio 1 (posts 1 - meta_key: numeroepisodio)
|_ Episodio 2 (posts 2 - meta_key: numeroepisodio)
|_ Episodio 3 (posts 3 - meta_key: numeroepisodio)
|_ Episodio 4 (posts 4 - meta_key: numeroepisodio)
|_ ...
|_ Temporada 2 (taxonomy: temporada)
|_ Episodio 1 (posts 1 - meta_key: numeroepisodio)
|_ Episodio 2 (posts 2 - meta_key: numeroepisodio)
|_ Episodio 3 (posts 3 - meta_key: numeroepisodio)
|_ Episodio 4 (posts 4 - meta_key: numeroepisodio)
|_ ...
Another Serie 1
|_ ...
Another Serie 2
|_ ...
Problem:
When I create my posts, the pagination are order by DATE. Can help me to make this order by meta_key, in same taxonomy only for current category?
Code:
<?php
$prev_post = get_adjacent_post( true, '', true );
$next_post = get_adjacent_post( true, '', false );
if ( !is_a( $next_post , 'WP_Post' ) ) {
$query_args = array (
'post_type' => 'post',
'posts_per_page' => -1,
'meta_key' => 'numeroepisodio',
'orderby' => 'meta_value meta_value_num',
'order' => 'DESC',
'paged' => $paged,
'tax_query' => array(
array( 'taxonomy' => 'categry'),
array( 'taxonomy' => 'temporada')
)
);
$oldest = get_posts($query_args);
$next_post = $oldest[0];
}
if ( !is_a( $prev_post , 'WP_Post' ) ) {
$latest = get_posts($query_args);
$prev_post = $latest[0];
}
?>
<?php if ( is_a( $prev_post , 'WP_Post' ) ) : ?>
<a href="<?php echo get_permalink( $prev_post->ID ); ?>"><div id="temporadas-dropdown"><i class="fa fa-caret-left"></i> ANTERIOR</div></a>
<?php endif; ?>
<?php if ( is_a( $next_post , 'WP_Post' ) ) : ?>
<a href="<?php echo get_permalink( $next_post->ID ); ?>"><div id="temporadas-dropdown">SIGUIENTE <i class="fa fa-caret-right"></i></div></a>
<?php endif; ?>
Here is a live example: http://series.enlatino.net/ver-online/silicon-valley/
Thanks so much in advice!