I am having a problem with the custom category template pagination and i search and read that using pre_get_posts fix the pagination problem. I read the pre_get_posts information in the WordPress Codex but i didn't understand how to use it.
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array(
'post_type' => 'post',
'meta_key' => 'hmeromhnia_lhkshs',
'orderby' => 'meta_value_num',
'order' => 'ASC',
'posts_per_page' => 9,
'paged' => $paged
);
// get results
query_posts( $args );?>
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post(); ?>
// The Loop
<?php endwhile;?>
<?php endif; ?>
<?php if ($wp_query->max_num_pages > 1) tie_pagenavi(); ?>
<?php wp_reset_query(); // Restore global post data stomped by the_post(). ?>
This is the code i use for the query and the pagination doesn't work. I can't understand where and when to insert the pre_get_posts. Generally don't know how to use it.
Please help me!