Support » Plugin: WP-PageNavi » How to add pagination links on single page

  • Resolved Exoskeletor


    i have create this shortcode

    function all_posts_mansory(){
    $output = '';
    			$args = array( 'post_status' => 'publish' );
    			$args['paged'] = get_query_var( 'paged' );
    			$curtitle = get_category_parents( get_query_var('cat') , false , ' - ' );
    			//echo headers
    			$output .= '<div class="section_title simple" id="section-title-5314721809a17" style="border-color: #dddddd;"><span class="title">Όλα τα Άρθρα</span></div><div id="clear-537bf6c690b21" class="clear"></div><style type="text/css">#clear-537bf6c690b21{padding-top:35px !important}</style>';
    			$output .= '<div class="post_list masonry isotope" style="display: block; position: relative; overflow: hidden; height:494px;">';
    			$recent_posts = new WP_Query( $args );
    			if ( $recent_posts->have_posts() ) {
    			    while ( $recent_posts->have_posts() ) {
    			        // do stuff
    							$num_posts = count($recent_posts);
    							//get ID,title,permalink etc
    							$recent_posts_usage = get_the_ID();
    							$this_ID = get_the_ID();
    							$post_class = join(" ", get_post_class('', $this_ID));
    							$this_title = get_the_title ();
    							$category = get_the_category ();
    							$this_category = $category[0]->cat_name;
    							$this_thumb = get_the_post_thumbnail( $this_ID, 'medium');
    							$this_permalink = get_the_permalink();
    							$page_data = get_page( $this_ID );
    							$excerpt = T2T_Toolkit::truncate_string(apply_filters('the_content', strip_tags($page_data->post_content)), 200);
    							//echo content
    							$output .= '<div class="callout_box with_post one_fourth isotope-item';
    										$output .= ' column_last';
    							} else {
    							$output .= '" style="position: absolute; left: 0px; top: 0px; -webkit-transform: translate3d(476px, 0px, 0px);">';
    							$output .= '<article id="post-'.$this_ID.'" class="'.$post_class.'">';
    							$output .= '	<a href="'.$this_permalink.'"> 	'.$this_thumb.' </a>';
    							$output .= '<div class="callout_box_content">';
    							$output .= '<h3>    <a href="'.$this_permalink.'">'.$this_title.' </a></h3>';
    							$output .= $excerpt;
    							$output .='</div>';
    							$output .='</article>';
    							$output .='</div>';
    			$output .='</div>';
    			return $output;
    add_shortcode('show_all_posts_mansory', 'all_posts_mansory');

    [Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]

    when i run it from my index.php wp page navi works nice but if i run this shortcode on a single page pagination works but the links above the articles doesnt show
    how i can fix it?
    Thanks for your great plugin

    also this is my page.php if it is helpfull

    <?php get_header(); ?>
    <section id="content">
      <div class="<?php echo get_post_meta(get_queried_object_id(), 'layout', true); ?> container">
        <?php while (have_posts()) : the_post(); ?>
          <div class="page_content">
            <?php the_content(); ?>
      	<?php endwhile; ?>
        <?php if(get_post_meta(get_queried_object_id(), 'layout', true) == "sidebar_right" || get_post_meta(get_queried_object_id(), 'layout', true) == "sidebar_left") { ?>
          <?php get_sidebar(); ?>
        <?php } ?>
      	<div class="clear"></div>
    <?php get_footer(); ?>

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Lester Chan


    Did you read the sticky

    There are instructions there. Please read through it.

    Basically you need to pass the WP_Query object to wp_pagenavi in order for it to read your query.

    ok if i change this

    to this
    wp_pagenavi( array( ‘query’ => $recent_posts) );
    i get the pagination but i get it not where i want them. it shows first in the page content and no matter where i put those 2 lines the pagination numbers position is always the same.

    Plugin Author Lester Chan


    Not too sure whether you can use paged or page, you want to try it and read

    is there any way instead of echo to take the output in another way?
    every time i use echo on functions the echo happens first on page content
    (i just want the code that wp-pagenavi echo to append in on $output instead of echo it with wp-pagenavi() how i can do that?)

    i have found a workaround for now:

    wp_pagenavi( array( 'query' => $recent_posts) );
    $output .= ob_get_contents();


Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How to add pagination links on single page’ is closed to new replies.