[resolved] How to add pagination links on single page (6 posts)

  1. Exoskeletor
    Posted 9 months ago #

    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 http://fit-life.info/author/andreas_ioannidis/ but if i run this shortcode on a single page pagination works but the links above the articles doesnt show http://fit-life.info/ola-ta-arthra/page/2/
    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(); ?>


  2. Lester Chan
    Plugin Author

    Posted 9 months ago #

    Did you read the sticky http://wordpress.org/support/topic/navigation-not-working-3?replies=1

    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.

  3. Exoskeletor
    Posted 9 months ago #

    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.

  4. Lester Chan
    Plugin Author

    Posted 9 months ago #

    Not too sure whether you can use paged or page, you want to try it and read http://codex.wordpress.org/Pagination

  5. Exoskeletor
    Posted 9 months ago #

    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?)

  6. Exoskeletor
    Posted 9 months ago #

    i have found a workaround for now:

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



You must log in to post.

About this Plugin

About this Topic


No tags yet.