Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

How to display pagination in a custom wp_query? WordPress

  • REFUNDED

I created a custom wp_query and as it is working the pagination doesn't! Here is the the whole code:

<?php get_header(); ?>
<div class="content-wrap">
<div class="content">
<?php tie_breadcrumbs() ?>
<?php $category_id = get_query_var('cat') ; ?>
<div class="page-head">
<h2 class="page-title">
<?php printf( __( 'Category Archives: %s', 'tie' ), '<span>' . single_cat_title( '', false ) . '</span>' ); ?>
</h2>
<?php if( tie_get_option( 'category_rss' ) ): ?>
<a class="rss-cat-icon ttip" title="<?php _e( 'Feed Subscription', 'tie' ); ?>" href=" <?php echo get_category_feed_link($category_id) ?>"><?php _e( 'Feed Subscription', 'tie' ); ?></a>
<?php endif; ?>
<div class="stripe-line"></div>

<?php
if( tie_get_option( 'category_desc' ) ):
$category_description = category_description();
if ( ! empty( $category_description ) )
echo '<div class="clear"></div><div class="archive-meta">' . $category_description . '</div>';
endif;
?>
</div>
<?php tie_include( 'slider-category' ) ?>


<?php
$args = array(
'post_type' => 'post',
'meta_key' => 'hmeromhnia_lhkshs',
'orderby' => 'meta_value_num',
'order' => 'ASC',
);


// get results
$the_query = new WP_Query( $args );

// The Loop
?>

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

<?php if( tie_get_option( 'blog_display' ) != 'full_thumb' ): ?>
<article class="item-list <?php echo'item_'.$count; ?>">
<h2 class="post-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'tie' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
<p class="post-meta">

<?php
if( get_field( "hmeromhnia_lhkshs" ) ): ?>
<span class="date"><?php the_field('hmeromhnia_lhkshs'); ?></span>
<?php endif;
?>

<?php
if( get_field( "wra_lhkshs" ) ): ?>
<span class="time"><?php the_field('wra_lhkshs'); ?></span>
<?php endif;
?>

<?php tie_get_time() ?>

<span class="category-label">
<?php
$caturls = array();
foreach( (get_the_category()) as $cat ):
$caturls[] = '<a href="' . get_category_link( $cat->cat_ID ) . '">' . $cat->cat_name . '</a> ';
endforeach;
echo implode( ', ', $caturls ); ?></span>

<span class="post-comments"><?php comments_popup_link( __( '0', 'tie' ), __( '1 Comment', 'tie' ), __( '% Comments', 'tie' ) ); ?></span>
</p>

<?php if( tie_get_option( 'blog_display' ) == 'content' ): ?>
<div class="entry">
<?php the_content( __( 'Read More &raquo;', 'tie' ) ); ?>
</div>
<?php else: ?>
<?php if ( function_exists("has_post_thumbnail") && has_post_thumbnail() ) : ?>
<div class="post-thumbnail">
<a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'tie' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark">
<?php tie_thumb('',200,200); ?>
<?php tie_get_score( true ); ?>
</a>
</div><!-- post-thumbnail /-->
<?php endif; ?>
<div class="entry">
<p><?php tie_excerpt() ?></p>
<a class="more-link" href="<?php the_permalink() ?>"><?php _e( 'Read More &raquo;', 'tie' ) ?></a>
</div>
<?php endif; ?>

<?php tie_include( 'post-share' ); // Get Share Button template ?>
<div class="clear"></div>
</article><!-- .item-list -->
<?php if( $count == 2 && tie_get_option( 'blog_display' ) == '2col' ): $count = 0; ?>
<div class="sep"></div>
<?php endif; ?>
<?php else: ?>
<article class="item-list">
<?php if ( function_exists("has_post_thumbnail") && has_post_thumbnail() ) : ?>
<div class="post-thumbnail single-post-thumb archive-wide-thumb">
<a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'tie' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php tie_thumb('', 620 , 330 ); ?><?php tie_get_score( true ); ?></a>
</div>
<?php endif; ?>
<h2 class="post-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'tie' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
<p class="post-meta">
<?php tie_get_time() ?>
<span class="post-comments"><?php comments_popup_link( __( '0', 'tie' ), __( '1 Comment', 'tie' ), __( '% Comments', 'tie' ) ); ?></span>
<?php echo tie_views(); ?>
</p>
<div class="entry">
<p><?php tie_excerpt() ?></p>
<a class="more-link" href="<?php the_permalink() ?>"><?php _e( 'Read More &raquo;', 'tie' ) ?></a>
</div>
<?php tie_include( 'post-share' ); // Get Share Button template ?>
<div class="clear"></div>
</article><!-- .item-list -->
<?php endif; ?>


<?php if ($the_query->max_num_pages > 1) tie_pagenavi(); ?>


<?php endwhile;?>
<?php endif; ?>

<?php wp_reset_query(); // Restore global post data stomped by the_post(). ?>

</div> <!-- .content -->

<?php get_sidebar(); ?>
<?php get_footer(); ?>


And here is the code that the autor uses for the tie_pagination in the theme-functions:

function tie_pagenavi(){
?>
<div class="pagination">
<?php tie_get_pagenavi() ?>
</div>
<?php
}


How can i make the pagination work in custom categories tempates with custom query?

Answers (5)

2013-06-10

Remy answers:

What's tie_get_pagenavi() code ?


haritos comments:

Here is the pagenavi.php! There should be the tie_get_pagenavi() code.
<?php
/*
Plugin >> Name: WP-PageNavi
Plugin URI: http://lesterchan.net/portfolio/programming/php/
Description: Adds a more advanced paging navigation to your WordPress blog.
Version: 2.50
Author: Lester 'GaMerZ' Chan
Author URI: http://lesterchan.net
*/


/*
Copyright 2009 Lester Chan (email : [email protected])

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/


### Function: Page Navigation: Boxed Style Paging
function tie_get_pagenavi($before = '', $after = '') {
global $wpdb, $wp_query;
$pagenavi_options = tie_pagenavi_init();

if (!is_single()) {
$request = $wp_query->request;
$posts_per_page = intval(get_query_var('posts_per_page'));
$paged = intval(get_query_var('paged'));
$numposts = $wp_query->found_posts;
$max_page = $wp_query->max_num_pages;
if(empty($paged) || $paged == 0) {
$paged = 1;
}
$pages_to_show = intval($pagenavi_options['num_pages']);
$larger_page_to_show = intval($pagenavi_options['num_larger_page_numbers']);
$larger_page_multiple = intval($pagenavi_options['larger_page_numbers_multiple']);
$pages_to_show_minus_1 = $pages_to_show - 1;
$half_page_start = floor($pages_to_show_minus_1/2);
$half_page_end = ceil($pages_to_show_minus_1/2);
$start_page = $paged - $half_page_start;
if($start_page <= 0) {
$start_page = 1;
}
$end_page = $paged + $half_page_end;
if(($end_page - $start_page) != $pages_to_show_minus_1) {
$end_page = $start_page + $pages_to_show_minus_1;
}
if($end_page > $max_page) {
$start_page = $max_page - $pages_to_show_minus_1;
$end_page = $max_page;
}
if($start_page <= 0) {
$start_page = 1;
}
$larger_per_page = $larger_page_to_show*$larger_page_multiple;
$larger_start_page_start = (tie_n_round($start_page, 10) + $larger_page_multiple) - $larger_per_page;
$larger_start_page_end = tie_n_round($start_page, 10) + $larger_page_multiple;
$larger_end_page_start = tie_n_round($end_page, 10) + $larger_page_multiple;
$larger_end_page_end = tie_n_round($end_page, 10) + ($larger_per_page);
if($larger_start_page_end - $larger_page_multiple == $start_page) {
$larger_start_page_start = $larger_start_page_start - $larger_page_multiple;
$larger_start_page_end = $larger_start_page_end - $larger_page_multiple;
}
if($larger_start_page_start <= 0) {
$larger_start_page_start = $larger_page_multiple;
}
if($larger_start_page_end > $max_page) {
$larger_start_page_end = $max_page;
}
if($larger_end_page_end > $max_page) {
$larger_end_page_end = $max_page;
}
if($max_page > 1 || intval($pagenavi_options['always_show']) == 1) {
$pages_text = str_replace("%CURRENT_PAGE%", number_format_i18n($paged), $pagenavi_options['pages_text']);
$pages_text = str_replace("%TOTAL_PAGES%", number_format_i18n($max_page), $pages_text);
//echo $before.'<div class="pagenavi">'."\n";

if(!empty($pages_text)) {
echo '<span class="pages">'.$pages_text.'</span>';
}
if ($start_page >= 2 && $pages_to_show < $max_page) {
$first_page_text = str_replace("%TOTAL_PAGES%", number_format_i18n($max_page), $pagenavi_options['first_text']);
echo '<a href="'.esc_url(get_pagenum_link()).'" class="first" title="'.$first_page_text.'">'.$first_page_text.'</a>';
if(!empty($pagenavi_options['dotleft_text'])) {
echo '<span class="extend">'.$pagenavi_options['dotleft_text'].'</span>';
}
}
if($larger_page_to_show > 0 && $larger_start_page_start > 0 && $larger_start_page_end <= $max_page) {
for($i = $larger_start_page_start; $i < $larger_start_page_end; $i+=$larger_page_multiple) {
$page_text = str_replace("%PAGE_NUMBER%", number_format_i18n($i), $pagenavi_options['page_text']);
echo '<a href="'.esc_url(get_pagenum_link($i)).'" class="page" title="'.$page_text.'">'.$page_text.'</a>';
}
}
previous_posts_link($pagenavi_options['prev_text']);
for($i = $start_page; $i <= $end_page; $i++) {
if($i == $paged) {
$current_page_text = str_replace("%PAGE_NUMBER%", number_format_i18n($i), $pagenavi_options['current_text']);
echo '<span class="current">'.$current_page_text.'</span>';
} else {
$page_text = str_replace("%PAGE_NUMBER%", number_format_i18n($i), $pagenavi_options['page_text']);
echo '<a href="'.esc_url(get_pagenum_link($i)).'" class="page" title="'.$page_text.'">'.$page_text.'</a>';
}
}
next_posts_link($pagenavi_options['next_text'], $max_page);
if($larger_page_to_show > 0 && $larger_end_page_start < $max_page) {
for($i = $larger_end_page_start; $i <= $larger_end_page_end; $i+=$larger_page_multiple) {
$page_text = str_replace("%PAGE_NUMBER%", number_format_i18n($i), $pagenavi_options['page_text']);
echo '<a href="'.esc_url(get_pagenum_link($i)).'" class="page" title="'.$page_text.'">'.$page_text.'</a>';
}
}
if ($end_page < $max_page) {
if(!empty($pagenavi_options['dotright_text'])) {
echo '<span class="extend">'.$pagenavi_options['dotright_text'].'</span>';
}
$last_page_text = str_replace("%TOTAL_PAGES%", number_format_i18n($max_page), $pagenavi_options['last_text']);
echo '<a href="'.esc_url(get_pagenum_link($max_page)).'" class="last" title="'.$last_page_text.'">'.$last_page_text.'</a>';
}

//echo '</div>'.$after."\n";
}
}
}


### Function: Round To The Nearest Value
function tie_n_round($num, $tonearest) {
return floor($num/$tonearest)*$tonearest;
}


### Function: Page Navigation Options
function tie_pagenavi_init() {
$pagenavi_options = array();
$pagenavi_options['pages_text'] = __('Page %CURRENT_PAGE% of %TOTAL_PAGES%','tie');
$pagenavi_options['current_text'] = '%PAGE_NUMBER%';
$pagenavi_options['page_text'] = '%PAGE_NUMBER%';
$pagenavi_options['first_text'] = __('&laquo; First','tie');
$pagenavi_options['last_text'] = __('Last &raquo;','tie');
$pagenavi_options['next_text'] = __('&raquo;','tie');
$pagenavi_options['prev_text'] = __('&laquo;','tie');
$pagenavi_options['dotright_text'] = __('...','tie');
$pagenavi_options['dotleft_text'] = __('...','tie');


$pagenavi_options['num_pages'] = 5;

$pagenavi_options['always_show'] = 0;
$pagenavi_options['num_larger_page_numbers'] = 3;
$pagenavi_options['larger_page_numbers_multiple'] = 10;

return $pagenavi_options;
}

?>


Remy comments:

This pagination can't work with your custom query, because in the tie_get_pagenavi() function (which is a modified wp-pagenavi plugin), the developer is using the default $wp_query of the displayed page to create the pagination. An alternative is using [[LINK href="http://codex.wordpress.org/Function_Reference/paginate_links"]][[/LINK]] which is a core WP function for creating a pagination.


haritos comments:

How can i do that?


Remy comments:

Can you show us the modified code ?


haritos comments:

<?php get_header(); ?>
<div class="content-wrap">
<div class="content">
<?php tie_breadcrumbs() ?>
<?php $category_id = get_query_var('cat') ; ?>
<div class="page-head">
<h2 class="page-title">
<?php printf( __( 'Category Archives: %s', 'tie' ), '<span>' . single_cat_title( '', false ) . '</span>' ); ?>
</h2>
<?php if( tie_get_option( 'category_rss' ) ): ?>
<a class="rss-cat-icon ttip" title="<?php _e( 'Feed Subscription', 'tie' ); ?>" href="<?php echo get_category_feed_link($category_id) ?>"><?php _e( 'Feed Subscription', 'tie' ); ?></a>
<?php endif; ?>
<div class="stripe-line"></div>

<?php
if( tie_get_option( 'category_desc' ) ):
$category_description = category_description();
if ( ! empty( $category_description ) )
echo '<div class="clear"></div><div class="archive-meta">' . $category_description . '</div>';
endif;
?>
</div>
<?php tie_include( 'slider-category' ) ?>


<?php

$args = array(

'posts_per_page'=> 8, //number of pages to display

'paged'=> $paged,

'post_type' => 'post',

'meta_key' => 'hmeromhnia_lhkshs',

'orderby' => 'meta_value_num',

'order' => 'ASC',

);



$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;



// get results

$the_query = new WP_Query( $args );

?>

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

<?php if( tie_get_option( 'blog_display' ) != 'full_thumb' ): ?>
<article class="item-list <?php echo'item_'.$count; ?>">
<h2 class="post-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'tie' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
<p class="post-meta">

<?php
if( get_field( "hmeromhnia_lhkshs" ) ): ?>
<span class="date"><?php the_field('hmeromhnia_lhkshs'); ?></span>
<?php endif;
?>

<?php
if( get_field( "wra_lhkshs" ) ): ?>
<span class="time"><?php the_field('wra_lhkshs'); ?></span>
<?php endif;
?>

<?php tie_get_time() ?>

<span class="category-label">
<?php
$caturls = array();
foreach( (get_the_category()) as $cat ):
$caturls[] = '<a href="' . get_category_link( $cat->cat_ID ) . '">' . $cat->cat_name . '</a> ';
endforeach;
echo implode( ', ', $caturls ); ?></span>

<span class="post-comments"><?php comments_popup_link( __( '0', 'tie' ), __( '1 Comment', 'tie' ), __( '% Comments', 'tie' ) ); ?></span>
</p>

<?php if( tie_get_option( 'blog_display' ) == 'content' ): ?>
<div class="entry">
<?php the_content( __( 'Read More &raquo;', 'tie' ) ); ?>
</div>
<?php else: ?>
<?php if ( function_exists("has_post_thumbnail") && has_post_thumbnail() ) : ?>
<div class="post-thumbnail">
<a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'tie' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark">
<?php tie_thumb('',200,200); ?>
<?php tie_get_score( true ); ?>
</a>
</div><!-- post-thumbnail /-->
<?php endif; ?>
<div class="entry">
<p><?php tie_excerpt() ?></p>
<a class="more-link" href="<?php the_permalink() ?>"><?php _e( 'Read More &raquo;', 'tie' ) ?></a>
</div>
<?php endif; ?>

<?php tie_include( 'post-share' ); // Get Share Button template ?>
<div class="clear"></div>
</article><!-- .item-list -->
<?php if( $count == 2 && tie_get_option( 'blog_display' ) == '2col' ): $count = 0; ?>
<div class="sep"></div>
<?php endif; ?>
<?php else: ?>
<article class="item-list">
<?php if ( function_exists("has_post_thumbnail") && has_post_thumbnail() ) : ?>
<div class="post-thumbnail single-post-thumb archive-wide-thumb">
<a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'tie' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php tie_thumb('', 620 , 330 ); ?><?php tie_get_score( true ); ?></a>
</div>
<?php endif; ?>
<h2 class="post-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'tie' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
<p class="post-meta">
<?php tie_get_time() ?>
<span class="post-comments"><?php comments_popup_link( __( '0', 'tie' ), __( '1 Comment', 'tie' ), __( '% Comments', 'tie' ) ); ?></span>
<?php echo tie_views(); ?>
</p>
<div class="entry">
<p><?php tie_excerpt() ?></p>
<a class="more-link" href="<?php the_permalink() ?>"><?php _e( 'Read More &raquo;', 'tie' ) ?></a>
</div>
<?php tie_include( 'post-share' ); // Get Share Button template ?>
<div class="clear"></div>
</article><!-- .item-list -->
<?php endif; ?>

<?php endwhile;?>
<?php endif; ?>

<nav>

<?php if (function_exists('wp_pagenavi')) wp_pagenavi(array('query' => $the_query)) ?>

</nav>

<?php wp_reset_query(); // Restore global post data stomped by the_post(). ?>

</div> <!-- .content -->

<?php get_sidebar(); ?>
<?php get_footer(); ?>


haritos comments:

<?php get_header(); ?>

<div class="content-wrap">

<div class="content">

<?php tie_breadcrumbs() ?>

<?php $category_id = get_query_var('cat') ; ?>

<div class="page-head">

<h2 class="page-title">

<?php printf( __( 'Category Archives: %s', 'tie' ), '<span>' . single_cat_title( '', false ) . '</span>' ); ?>

</h2>

<?php if( tie_get_option( 'category_rss' ) ): ?>

<a class="rss-cat-icon ttip" title="<?php _e( 'Feed Subscription', 'tie' ); ?>" href="<?php echo get_category_feed_link($category_id) ?>"><?php _e( 'Feed Subscription', 'tie' ); ?></a>

<?php endif; ?>

<div class="stripe-line"></div>



<?php

if( tie_get_option( 'category_desc' ) ):

$category_description = category_description();

if ( ! empty( $category_description ) )

echo '<div class="clear"></div><div class="archive-meta">' . $category_description . '</div>';

endif;

?>

</div>

<?php tie_include( 'slider-category' ) ?>





<?php



$args = array(



'posts_per_page'=> 8, //number of pages to display



'paged'=> $paged,



'post_type' => 'post',



'meta_key' => 'hmeromhnia_lhkshs',



'orderby' => 'meta_value_num',



'order' => 'ASC',



);







$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;







// get results



$the_query = new WP_Query( $args );



?>



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

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



<?php if( tie_get_option( 'blog_display' ) != 'full_thumb' ): ?>

<article class="item-list <?php echo'item_'.$count; ?>">

<h2 class="post-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'tie' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>

<p class="post-meta">



<?php

if( get_field( "hmeromhnia_lhkshs" ) ): ?>

<span class="date"><?php the_field('hmeromhnia_lhkshs'); ?></span>

<?php endif;

?>



<?php

if( get_field( "wra_lhkshs" ) ): ?>

<span class="time"><?php the_field('wra_lhkshs'); ?></span>

<?php endif;

?>



<?php tie_get_time() ?>



<span class="category-label">

<?php

$caturls = array();

foreach( (get_the_category()) as $cat ):

$caturls[] = '<a href="' . get_category_link( $cat->cat_ID ) . '">' . $cat->cat_name . '</a> ';

endforeach;

echo implode( ', ', $caturls ); ?></span>



<span class="post-comments"><?php comments_popup_link( __( '0', 'tie' ), __( '1 Comment', 'tie' ), __( '% Comments', 'tie' ) ); ?></span>

</p>



<?php if( tie_get_option( 'blog_display' ) == 'content' ): ?>

<div class="entry">

<?php the_content( __( 'Read More &raquo;', 'tie' ) ); ?>

</div>

<?php else: ?>

<?php if ( function_exists("has_post_thumbnail") && has_post_thumbnail() ) : ?>

<div class="post-thumbnail">

<a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'tie' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark">

<?php tie_thumb('',200,200); ?>

<?php tie_get_score( true ); ?>

</a>

</div><!-- post-thumbnail /-->

<?php endif; ?>

<div class="entry">

<p><?php tie_excerpt() ?></p>

<a class="more-link" href="<?php the_permalink() ?>"><?php _e( 'Read More &raquo;', 'tie' ) ?></a>

</div>

<?php endif; ?>



<?php tie_include( 'post-share' ); // Get Share Button template ?>

<div class="clear"></div>

</article><!-- .item-list -->

<?php if( $count == 2 && tie_get_option( 'blog_display' ) == '2col' ): $count = 0; ?>

<div class="sep"></div>

<?php endif; ?>

<?php else: ?>

<article class="item-list">

<?php if ( function_exists("has_post_thumbnail") && has_post_thumbnail() ) : ?>

<div class="post-thumbnail single-post-thumb archive-wide-thumb">

<a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'tie' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php tie_thumb('', 620 , 330 ); ?><?php tie_get_score( true ); ?></a>

</div>

<?php endif; ?>

<h2 class="post-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'tie' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>

<p class="post-meta">

<?php tie_get_time() ?>

<span class="post-comments"><?php comments_popup_link( __( '0', 'tie' ), __( '1 Comment', 'tie' ), __( '% Comments', 'tie' ) ); ?></span>

<?php echo tie_views(); ?>

</p>

<div class="entry">

<p><?php tie_excerpt() ?></p>

<a class="more-link" href="<?php the_permalink() ?>"><?php _e( 'Read More &raquo;', 'tie' ) ?></a>

</div>

<?php tie_include( 'post-share' ); // Get Share Button template ?>

<div class="clear"></div>

</article><!-- .item-list -->

<?php endif; ?>



<?php endwhile;?>

<?php endif; ?>



<nav>



<?php if (function_exists('wp_pagenavi')) wp_pagenavi(array('query' => $the_query)) ?>



</nav>



<?php wp_reset_query(); // Restore global post data stomped by the_post(). ?>



</div> <!-- .content -->



<?php get_sidebar(); ?>

<?php get_footer(); ?>


Remy comments:

This is supposed to work if you have wp_pagenavi plugin installed, the code looks ok. Nothing displays on your end ?


haritos comments:

Nothing at all..

2013-06-10

Hariprasad Vijayan answers:

Hello,

Are you using any plugin for pagination?


haritos comments:

No i don't use any but i have the impression that the theme autor has the WP-PageNavi plugin implemented in the theme!


Hariprasad Vijayan comments:

Hello,

I think wp pagenavi customized and used here,
Install http://wordpress.org/plugins/wp-pagenavi/ and use following code for pagination
wp_pagenavi( array( 'query' => $the_query) );


haritos comments:

That didn't work because it gives a 404 error page in the second page!


Hariprasad Vijayan comments:

Install Category pagination fix plugin

http://wordpress.org/plugins/category-pagination-fix/


haritos comments:

That didn't work!


Hariprasad Vijayan comments:

Okay.. How many post you want to display on that page? I mean how many post that you are displaying on that page?


haritos comments:

8 posts


Hariprasad Vijayan comments:

Go to the Settings tab in your wordpress dashboard
Go to the Reading tab.
Change the Blog pages show at most from the default 10 to 8

Hope this will work.


Hariprasad Vijayan comments:

Do the following changes in your WP_Query $args section

$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'=> 8,
'paged'=> $paged,
);

2013-06-10

Alfonso Abarca Alvarez answers:

hi haritos

no need to modify the plugin

whit the original plugin, insert this code in your theme

<nav>
<?php if (function_exists('wp_pagenavi')) wp_pagenavi(array('query' => $the_query)) ?>
</nav>


haritos comments:

But the plugin is implemented into this theme: [[LINK href="http://themeforest.net/item/jarida-responsive-wordpress-news-magazine-blog/4309191?WT.ac=follow&WT.seg_1=follow&WT.z_author=mo3aser"]][[/LINK]]


haritos comments:

http://themeforest.net/item/jarida-responsive-wordpress-news-magazine-blog/4309191?WT.ac=follow&WT.seg_1=follow&WT.z_author=mo3aser


Alfonso Abarca Alvarez comments:


You can do the following:

1.- Install wp_pagenavi

2.- make your query whit WP_Query for Example:

<?php
$args = array(
'posts_per_page'=> 10, //number of pages to display
'paged'=> $paged,
'post_type' => 'post',
'meta_key' => 'hmeromhnia_lhkshs',
'orderby' => 'meta_value_num',
'order' => 'ASC',
);

$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;

// get results
$the_query = new WP_Query( $args );
?>

3.- display your content and after while insert the nav
<nav>
<?php if (function_exists('wp_pagenavi')) wp_pagenavi(array('query' => $the_query)) ?>
</nav>


Alfonso Abarca Alvarez comments:

maybe you can delete the plugin and use normal WP_Pagenavi


http://scribu.net/wordpress/wp-pagenavi/wpn-2-74.html


Alfonso Abarca Alvarez comments:

1.- Install wp_pagenavi

2.- make your query whit WP_Query for Example:

<?php
$args = array(
'posts_per_page'=> 10, //number of pages to display
'paged'=> $paged,
'post_type' => 'post',
'meta_key' => 'hmeromhnia_lhkshs',
'orderby' => 'meta_value_num',
'order' => 'ASC',
);

$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;

// get results
$the_query = new WP_Query( $args );
?>

3.- display your content and after while insert the nav

<nav>
<?php if (function_exists('wp_pagenavi')) wp_pagenavi(array('query' => $the_query)) ?>
</nav>


haritos comments:

Doesn't work!


haritos comments:

<?php get_header(); ?>
<div class="content-wrap">
<div class="content">
<?php tie_breadcrumbs() ?>
<?php $category_id = get_query_var('cat') ; ?>
<div class="page-head">
<h2 class="page-title">
<?php printf( __( 'Category Archives: %s', 'tie' ), '<span>' . single_cat_title( '', false ) . '</span>' ); ?>
</h2>
<?php if( tie_get_option( 'category_rss' ) ): ?>
<a class="rss-cat-icon ttip" title="<?php _e( 'Feed Subscription', 'tie' ); ?>" href="<?php echo get_category_feed_link($category_id) ?>"><?php _e( 'Feed Subscription', 'tie' ); ?></a>
<?php endif; ?>
<div class="stripe-line"></div>

<?php
if( tie_get_option( 'category_desc' ) ):
$category_description = category_description();
if ( ! empty( $category_description ) )
echo '<div class="clear"></div><div class="archive-meta">' . $category_description . '</div>';
endif;
?>
</div>
<?php tie_include( 'slider-category' ) ?>


<?php

$args = array(

'posts_per_page'=> 8, //number of pages to display

'paged'=> $paged,

'post_type' => 'post',

'meta_key' => 'hmeromhnia_lhkshs',

'orderby' => 'meta_value_num',

'order' => 'ASC',

);



$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;



// get results

$the_query = new WP_Query( $args );

?>

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

<?php if( tie_get_option( 'blog_display' ) != 'full_thumb' ): ?>
<article class="item-list <?php echo'item_'.$count; ?>">
<h2 class="post-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'tie' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
<p class="post-meta">

<?php
if( get_field( "hmeromhnia_lhkshs" ) ): ?>
<span class="date"><?php the_field('hmeromhnia_lhkshs'); ?></span>
<?php endif;
?>

<?php
if( get_field( "wra_lhkshs" ) ): ?>
<span class="time"><?php the_field('wra_lhkshs'); ?></span>
<?php endif;
?>

<?php tie_get_time() ?>

<span class="category-label">
<?php
$caturls = array();
foreach( (get_the_category()) as $cat ):
$caturls[] = '<a href="' . get_category_link( $cat->cat_ID ) . '">' . $cat->cat_name . '</a> ';
endforeach;
echo implode( ', ', $caturls ); ?></span>

<span class="post-comments"><?php comments_popup_link( __( '0', 'tie' ), __( '1 Comment', 'tie' ), __( '% Comments', 'tie' ) ); ?></span>
</p>

<?php if( tie_get_option( 'blog_display' ) == 'content' ): ?>
<div class="entry">
<?php the_content( __( 'Read More &raquo;', 'tie' ) ); ?>
</div>
<?php else: ?>
<?php if ( function_exists("has_post_thumbnail") && has_post_thumbnail() ) : ?>
<div class="post-thumbnail">
<a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'tie' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark">
<?php tie_thumb('',200,200); ?>
<?php tie_get_score( true ); ?>
</a>
</div><!-- post-thumbnail /-->
<?php endif; ?>
<div class="entry">
<p><?php tie_excerpt() ?></p>
<a class="more-link" href="<?php the_permalink() ?>"><?php _e( 'Read More &raquo;', 'tie' ) ?></a>
</div>
<?php endif; ?>

<?php tie_include( 'post-share' ); // Get Share Button template ?>
<div class="clear"></div>
</article><!-- .item-list -->
<?php if( $count == 2 && tie_get_option( 'blog_display' ) == '2col' ): $count = 0; ?>
<div class="sep"></div>
<?php endif; ?>
<?php else: ?>
<article class="item-list">
<?php if ( function_exists("has_post_thumbnail") && has_post_thumbnail() ) : ?>
<div class="post-thumbnail single-post-thumb archive-wide-thumb">
<a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'tie' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php tie_thumb('', 620 , 330 ); ?><?php tie_get_score( true ); ?></a>
</div>
<?php endif; ?>
<h2 class="post-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'tie' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
<p class="post-meta">
<?php tie_get_time() ?>
<span class="post-comments"><?php comments_popup_link( __( '0', 'tie' ), __( '1 Comment', 'tie' ), __( '% Comments', 'tie' ) ); ?></span>
<?php echo tie_views(); ?>
</p>
<div class="entry">
<p><?php tie_excerpt() ?></p>
<a class="more-link" href="<?php the_permalink() ?>"><?php _e( 'Read More &raquo;', 'tie' ) ?></a>
</div>
<?php tie_include( 'post-share' ); // Get Share Button template ?>
<div class="clear"></div>
</article><!-- .item-list -->
<?php endif; ?>

<?php endwhile;?>
<?php endif; ?>

<nav>

<?php if (function_exists('wp_pagenavi')) wp_pagenavi(array('query' => $the_query)) ?>

</nav>

<?php wp_reset_query(); // Restore global post data stomped by the_post(). ?>

</div> <!-- .content -->

<?php get_sidebar(); ?>
<?php get_footer(); ?>

2013-06-12

Broeiend answers:

Try defining the globals before the query:



// defining globals
global $WP_Query;
global $post;

$args = array(
'posts_per_page'=> 8, //number of pages to display
'paged'=> $paged,
'post_type' => 'post',
'meta_key' => 'hmeromhnia_lhkshs',
'orderby' => 'meta_value_num',
'order' => 'ASC',
);


2013-06-12

isp_charlie answers:

try my functions


<?php
function page_navi($max_page = '' , $page_custom = '', $before = '', $after = '') {
global $wpdb, $wp_query;
if(empty($page_custom)) {
$paged = intval(get_query_var('paged'));
} else {
$paged = $page_custom;
}


$posts_per_page = intval(get_query_var('posts_per_page'));

if(empty($max_page)) {
$max_page = $wp_query->max_num_pages;
} else {
$max_page = ceil($max_page/$posts_per_page);
}

if(empty($paged) || $paged == 0) {
$paged = ;
}
$pages_to_show = 10;
$pages_to_show_minus_= $pages_to_show-;
$half_page_start = floor($pages_to_show_minus_/2);
$half_page_end = ceil($pages_to_show_minus_/2);
$start_page = $paged - $half_page_start;
if($start_page <= 0) {
$start_page = ;
}
$end_page = $paged + $half_page_end;
if(($end_page - $start_page) != $pages_to_show_minus_) {
$end_page = $start_page + $pages_to_show_minus_;
}
if($end_page > $max_page) {
$start_page = $max_page - $pages_to_show_minus_;
$end_page = $max_page;
}
if($start_page <= 0) {
$start_page = ;
}


echo '<div class="clearfix pagging">';

for($i = $start_page; $i <= $end_page; $i++) {
if($i == $paged) {
echo '<span>'.$i.'</span>';
} else {
echo '<a href="'.get_pagenum_link($i).'">'.$i.'</a>';
}
}


echo '</div>';
}
?>



use:

add this code before loop has custom query_posts

$paged = (get_query_var('paged')) ? get_query_var('paged') : ;


page navi:
<?php page_navi("",$paged); ?>