Support » Plugin: Ajax Pagination and Infinite Scroll » Ajax Pagination for function related_posts !!

  • Resolved akhbarelyaom

    (@akhbarelyaom)


    Hi 🙂

    I have a code i wrote it years ago for function related_post like this

    <?php
    
    function related_posts(){
    
    	global $get_meta , $post;
    
    	global $post;
    
    	$orig_post = $post;
    
    	//$query_type = tie_get_option('related_query') ;
    
        $categories = get_the_category( $post->ID );  
        $first_cat = $categories[0]->cat_ID; 
    	$tags = wp_get_post_tags($post->ID);
    
    	$tags_ids = array();
    
    	foreach($tags as $individual_tag) $tags_ids[] = $individual_tag->term_id;
    
    	$args=array('post__not_in' => array($post->ID),'posts_per_page'=> 16 , 'category__in'=> $first_cat);
    
    	$attr = array( 'class' => "attachment-catego" );
    
    	$related_query = new wp_query( $args );
    
    	if( $related_query->have_posts() ) : $count=0;?>
    
    	<section id="related_posts">
    
    		<div class="block-head">
    
    			<h3>مقالات ممكن ان تعجبك</h3><div class="stripe-line"></div>
    
    		</div>
    
    		<div class="post-listing">
    
    			<?php while ( $related_query->have_posts() ) : $related_query->the_post()?>
    
    			<div class="related-item">
    
    				<?php if ( function_exists("has_post_thumbnail") && has_post_thumbnail() ) : ?>			
    
    				<div class="post-thumbnail">
    
    					<a href="<?php the_permalink(); ?>" title="<?php echo get_the_title(); ?>" rel="bookmark">
    
    						<?php echo get_the_post_thumbnail( get_the_ID(), 'catego', $attr ); ?>
    
    					</a>
    
    				</div><!-- post-thumbnail /-->
    
    <h3><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" rel="bookmark"><?php echo mb_substr(get_the_title(), 0, 87); ?></a></h3>
    				<div class="entry"><a href="<?php echo get_permalink(); ?>" title="<?php echo get_the_title(); ?>"></div>
    
    				<p class="post-meta"><?php /*tie_get_time()*/ ?></p>
    
    				<?php endif; ?>			
    
    				
    			</div>
    
    			<?php endwhile;?>
    
    			<div class="clear"></div>
    
    		</div>
    
    	</section>
    
    	<?php	endif;
    
    	$post = $orig_post;
    
    	wp_reset_query();
    
    }
    
    ?>

    and i load the template like this <?php related_posts(); ?>

    which load recent posts after the current post in a posting list like in this link
    http://www.akhbarelyaom.com/618579

    the problem here that i can’t make pages for this list to load and show the next list content … i tried to do the steps in Multiple Posts Set Up here: http://wordpress-ajax-pagination.com/multiple-posts-set-up

    but could not make it right and i searched for 3 days to make pagination for this function but i can’t.

    Can you help me to set up the right code to use the plugin with load more option with this list ?

    Your help is really appreciated 🙂

  • The topic ‘Ajax Pagination for function related_posts !!’ is closed to new replies.