Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author craigramsay

    (@malinkymedia)

    Good question and in theory yes. I imagine you will be using WP_Query to fetch the posts based on the filters chosen and therefore those queries could still be paginated like any other query but you’re just changing the parameters each time.

    Do you standard WordPress pagination anyway? I couldn’t see any?

    Thread Starter dpope0824

    (@dpope0824)

    No I do not, it does not recognize the “need” for pagination, it could be a problem in my code but it’s beyond my understanding. Have been out of the loop for awhile and still trying to catch up.

    <?php
    
    	if(isset($_POST['filter']))
    	{
    		$fbytype = $_POST['bytype'];
    		$fbytopic = $_POST['bytopic'];
    		$fbyregion = $_POST['byregion'];
    
    		$fsortby = $_POST['sortby'];
    		$fview = $_POST['view'];
    		$ispodcast = false;
    
    		require('../../../wp-blog-header.php'); 
    
    		if($fsortby=="recent"):
    			global $post;
    
                  $args= array
        (
            'offset'=>$offset,
            'cat' => 6,
            'paged'=>$paged,
            'orderby' => 'title',
            'order' => 'ASC'
        );
    		$posts = query_posts("$args");
    
    		if ( have_posts() )
    		{
    
    			if($fview=="grid")
    			{
    				grid_style();
    				while ( have_posts() )
    				{
    					$ispodcast = false;
    					the_post(); 
    
    					if(chechcategory($post->ID,$fbytype))
    					{
    						//echo chechcategory($post->ID,$fbytype).' : '.$post->ID .' : '.$fbytype.'<br>';
    						if(chechcategory($post->ID,$fbytopic))
    						{
    							//echo chechcategory($post->ID,$fbytopic).' : '.$post->ID .' : '.$fbytopic.'<br>';
    							if(chechcategory($post->ID,$fbyregion))
    							{
    								//echo chechcategory($post->ID,$fbyregion).' : '.$post->ID .' : '.$fbyregion.'<br>';
    								if(in_category(array(7),$post->ID))
    									$ispodcast = true;
    
    								$thumbsrc = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );
    								?>
    
    								<div class="result-container">
    									<div class="result-title">
    										<a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a>
    									</div>
    
    									<?php 
    
    									if($ispodcast)
    									{
    										?>
    										<div class="result-image">
    											<a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>"><img src="<?php echo $thumbsrc; ?>" height="100px" width="210px" alt="Link to <?php the_title(); ?>"/> </a><a class="podcast-overlay" href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>">
    											<div class="podcast-overlay"></div>
    											</a>
    										</div>
    
    										<?php
    									}
    									else
    									{
    										?>
    										<div class="result-image">
    											<a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>"><img src="<?php echo $thumbsrc; ?>" height="100px" width="210px" alt="Link to <?php the_title(); ?>"/> </a>
    										</div>
    
    										<?php
    									}
    									?>
    
    									<div class="result-text"><?php the_excerpt_max_charlength(108,$post->ID);//the_excerpt(); ?></div>
    								</div>
    
    								<?php
    							}
    						}
    					}
    				}
    			}
    			else
    			{
    				list_style();
    				while ( have_posts() )
    				{
    					$ispodcast = false;
    					the_post(); 
    
    					if(chechcategory($post->ID,$fbytype))
    					{
    						//echo chechcategory($post->ID,$fbytype).' : '.$post->ID .' : '.$fbytype.'<br>';
    						if(chechcategory($post->ID,$fbytopic))
    						{
    							//echo chechcategory($post->ID,$fbytopic).' : '.$post->ID .' : '.$fbytopic.'<br>';
    							if(chechcategory($post->ID,$fbyregion))
    							{
    								//echo chechcategory($post->ID,$fbyregion).' : '.$post->ID .' : '.$fbyregion.'<br>';
    								if(in_category(array(7),$post->ID))
    									$ispodcast = true;
    
    								$thumbsrc = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );
    								?>
    
    								<div class="result-container">
    									<div class="result-left">
    			                        <?php
    									if($ispodcast)
    									{
    										?>
    										<div class="result-image">
    											<a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>"><img src="<?php echo $thumbsrc; ?>" height="100px" width="210px" alt="Link to <?php the_title(); ?>"/></a><a class="podcast-overlay" href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>">
    											<div class="podcast-overlay"></div>
    											</a>
    										</div>
    
    										<?php
    									}
    									else
    									{
    										?>
    										<div class="result-image">
    											<a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>"><img src="<?php echo $thumbsrc; ?>" height="100px" width="210px" alt="Link to <?php the_title(); ?>"/></a>
    										</div>
    										<?php
    									}
    									?>
    									</div>
    
    									<div class="result-right">
    										<div class="result-title">
    											<a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a>
    										</div>
    
    										<div class="result-text">
    											<?php the_excerpt_max_charlength(108,$post->ID);//the_excerpt(); ?>
    										</div>
    									</div>	
    
    								</div>
    
    								<?php
    								}
    							}
    						}
    					}
    				}
    			}
    
    			endif;
    
    			if($fsortby=="shared" || $fsortby=="popular"):
    				$querystr = "
    				SELECT $wpdb->posts.*, CONVERT($wpdb->postmeta.meta_value,UNSIGNED INTEGER) AS Count
    				FROM $wpdb->posts, $wpdb->postmeta
    				WHERE $wpdb->posts.ID = $wpdb->postmeta.post_id ";
    
    			if($fsortby=="shared")
    				$querystr.="AND $wpdb->postmeta.meta_key = 'total-share'";
    			else
    				$querystr.="AND $wpdb->postmeta.meta_key = 'total-count'";
    			$querystr.="
    			AND $wpdb->posts.post_status = 'publish'
    			AND $wpdb->posts.post_type = 'post'
    			AND $wpdb->posts.post_date < NOW()
    			ORDER BY Count DESC ";
    
    			$pageposts = $wpdb->get_results($querystr, OBJECT);
    			if ( $pageposts )
    			{
    				if($fview=="grid")
    				{
    					grid_style();
    					global $post;
    
    					foreach ($pageposts as $post)
    					{
    						$ispodcast = false;
    						setup_postdata($post);
    
    						if(!chechcategory($post->ID,1))
    							if(chechcategory($post->ID,$fbytype))
    							{
    								//echo chechcategory($post->ID,$fbytype).' : '.$post->ID .' : '.$fbytype.'<br>';
    								if(chechcategory($post->ID,$fbytopic))
    								{
    									//echo chechcategory($post->ID,$fbytopic).' : '.$post->ID .' : '.$fbytopic.'<br>';
    									if(chechcategory($post->ID,$fbyregion))
    									{
    										//echo chechcategory($post->ID,$fbyregion).' : '.$post->ID .' : '.$fbyregion.'<br>';
    										if(in_category(array(7),$post->ID))
    											$ispodcast = true;
    										$thumbsrc = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );
    										?>
    
    										<div class="result-container">
    											<div class="result-title">
    												<a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a>
    											</div>
    
    											<?php
    											if($ispodcast)
    											{
    												?>
    												<div class="result-image">
    													<a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>"><img src="<?php echo $thumbsrc; ?>" height="100px" width="210px" alt="Link to <?php the_title(); ?>"/></a><a class="podcast-overlay" href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>">
    
    													<div class="podcast-overlay"></div>
    													</a>
    												</div>
    												<?php
    											}
    											else
    											{
    												?>
    												<div class="result-image">
    													<a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>"><img src="<?php echo $thumbsrc; ?>" height="100px" width="210px" alt="Link to <?php the_title(); ?>"/></a>
    												</div>
    												<?php
    											}
    											?>
    											<div class="result-text"><?php the_excerpt_max_charlength(108,$post->ID);//the_excerpt(); ?></div>
    										</div>
    
    										<?php
    									}
    								}
    							}
    						}
    					}
    					else
    					{
    						list_style();
    						global $post;
    
    						foreach ($pageposts as $post)
    						{
    							$ispodcast = false;
    							setup_postdata($post);
    
    							if(!chechcategory($post->ID,1))
    								if(chechcategory($post->ID,$fbytype))
    								{
    									//echo chechcategory($post->ID,$fbytype).' : '.$post->ID .' : '.$fbytype.'<br>';
    									if(chechcategory($post->ID,$fbytopic))
    									{
    										//echo chechcategory($post->ID,$fbytopic).' : '.$post->ID .' : '.$fbytopic.'<br>';
    										if(chechcategory($post->ID,$fbyregion))
    										{
    											//echo chechcategory($post->ID,$fbyregion).' : '.$post->ID .' : '.$fbyregion.'<br>';
    											if(in_category(array(7),$post->ID))
    												$ispodcast = true;
    
    											$thumbsrc = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );
    											?>
    
    											<div class="result-container">
    												<div class="result-left">
    			 									<?php
    												if($ispodcast)
    												{
    													?>
    													<div class="result-image">
    														<a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>"><img src="<?php echo $thumbsrc; ?>" height="100px" width="210px" alt="Link to <?php the_title(); ?>"/></a><a class="podcast-overlay" href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>"><div class="podcast-overlay"></div></a>
    													</div>
    
    													<?php
    												}
    												else
    												{
    													?>
    													<div class="result-image">
    														<a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>"><img src="<?php echo $thumbsrc; ?>" height="100px" width="210px" alt="Link to <?php the_title(); ?>"/></a>
    													</div>
    
    													<?php
    												}
    												?>
    												</div>
    
    												<div class="result-right">
    													<div class="result-title">
    														<a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a>
    													</div>
    
    													<div class="result-text">
    														<?php the_excerpt_max_charlength(108,$post->ID);//the_excerpt(); ?>
    													</div>
    												</div>
    											</div>
    
    											<?php
    											}
    										}
    									}
    								}
    							}
    						}
    						endif;
    
    					}
    
    					function grid_style()
    					{
    						echo '	<style>	#search-filter-page-continer .result-container		{						float:left;			margin-left: 18px;			padding-bottom: 40px;			width: 220px; height:215px;		}		#search-filter-page-continer .result-container .result-title		{			text-transform: uppercase;			font-weight: bold;			font-size:12px;	height:32px; line-height:16px;	}		#search-filter-page-continer .result-container .result-image		{ position:relative;			margin:10px 0px;			border: 1px solid #E1DEDE;			width:210px;			height:100px;					}		#search-filter-page-continer .result-container .result-text		{			overflow:hidden;			height:57px;			width:100%;		}</style>';
    
    					}
    
    					function list_style()
    					{
    
    						echo '<style> #search-filter-page-continer .result-container{	padding-bottom: 40px;			width: 100%;			height:140px;	padding-left:30px; position:relative; display:block;	}		#search-filter-page-continer .result-container .result-left		{			float:left;			width:220px;		}		#search-filter-page-continer .result-container .result-right		{			float:left;			margin-left: 30px;	 margin-top: 10px;		width: 520px;		}		#search-filter-page-continer .result-container .result-title		{			text-transform: uppercase;			font-weight: bold;			font-size:14px;					}		#search-filter-page-continer .result-container .result-image		{ position:relative;			border: 1px solid #E1DEDE;			width:210px;			height:100px;					}		#search-filter-page-continer .result-container .result-text		{			overflow:hidden;						width:100%;			height:58px;			margin-top: 15px;		}</style>';
    					}
    
    					function chechcategory($id,$category)
    					{
    						if($category=="")
    							return true;
    						return in_category(explode(',',$category),$id);
    					}
    
    					function the_excerpt_max_charlength($charlength,$id)
    					{
    
    						$synopses = get_post_meta($id,'synopsis',true);
    						if($synopses=="")
    							$synopses = get_the_excerpt();//get_post_meta($id, 'thumbnail-copy', true);
    
    						$excerpt=$synopses;
    						$excerpt = str_replace('[quote]','',$excerpt);
    						$charlength++;
    
    						if ( mb_strlen( $excerpt ) > $charlength )
    						{
    							$subex = mb_substr( $excerpt, 0, $charlength - 5 );
    							$exwords = explode( ' ', $subex );
    							$excut = - ( mb_strlen( $exwords[ count( $exwords ) - 1 ] ) );
    							if ( $excut < 0 )
    							{
    								echo mb_substr( $subex, 0, $excut );
    							}
    							else
    							{
    								echo $subex;
    							}
    							echo '...';
    						}
    						else
    						{
    							echo $excerpt;
    						}
    					}
    				?>

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Pagination On a Search filter using ajax’ is closed to new replies.