Limited number of products displayed on portfolio page
On the portfolio page I want to a limited number of products. I have 300
products and that's too much to be all on one page.
I put this code for limited number of products (10 products per page)
'posts_per_page' => 10
And I put this code for insert page switching (in this case 30 page)
<!-- Pagination -->
<?php if(function_exists('pagination')){ pagination(); }else{
paginate_links(); } ?>
<!-- Pagination End -->
And in fact both codes work. Number of shown products is limited to 10
products. At the bottom of the page I got the option to switch to one of
the 30 pages.
But whatever number page I click, I always opened the first 10 the
products of.
Portfolio page - PHP Code
<?php
/*
Template Name: Portfolio 4 Column
*/
?>
<?php get_header(); ?>
<?php
if ( function_exists( 'get_option_tree') ) {
$tune_portfoliolock = get_option_tree(
'value_portfolio4columnlock' );
if($tune_portfoliolock != 0 && $tune_portfoliolock != ""){
$tune_pih = $tune_portfoliolock; }else{ $tune_pih = null; }
}
$templateurl = get_template_directory_uri();
$pagecustoms = getOptions();
if (isset($pagecustoms["header_title"])){$tune_htitle =
$pagecustoms['header_title'];}else{$tune_htitle = "";}
if (isset($pagecustoms["sidebar_orientation"])){$tune_sideo =
$pagecustoms['sidebar_orientation'];}else{$tune_sideo = 1;}
if ($tune_sideo == 0){$conorient = "right"; $sideoffset = "";
$conoffset = "offset-by-one";}else{$conorient = "left"; $sideoffset =
"offset-by-one"; $conoffset = "";}
if (isset($pagecustoms["sidebar"])){$tune_sidebar =
$pagecustoms["sidebar"];}else{$tune_sidebar = "Page Sidebar";}
if (isset($pagecustoms["portfolio_category"])){
$ptype = $pagecustoms['portfolio_category'];
$pcat = "category_".$ptype;
}
if (isset($pagecustoms["portfolio_alpha"])){
if($pagecustoms['portfolio_alpha']!=""){$tune_folioalpha =
$pagecustoms['portfolio_alpha'];}else{$tune_folioalpha = 0;}}else{
$tune_folioalpha = 0;}
?>
<!-- Text Block
================================================== -->
<?php if(have_posts()) : while(have_posts()) : the_post(); ?>
<?php if( get_the_content() != ""){ ?>
<div class="sixteen columns row textblock">
<?php } else { ?>
<div class="sixteen columns row textblock" style="margin-top: -26px;">
<?php } the_content(); endwhile; endif; ?><div class="clear"></div>
</div>
<?php
$args=array(
'post_type' => $ptype,
'posts_per_page' => 10
);
$temp = $wp_query;
$wp_query = null;
$wp_query = new WP_Query();
$wp_query->query($args);
$terms = get_terms($pcat);
?>
<!-- Portfolio Filters
================================================== -->
<div class="sixteen columns row noheadline"></div>
<div class="sixteen columns row portfolio_filter">
<ul>
<?php
echo '<li><a class="portfolio_selector" data-group="all-group"
href="#">'.__('All Projects',
'tune').'</a><span>·</span></li>';
foreach ( $terms as $term ) {
$filter_last_item = end($terms);
if($term!=$filter_last_item){
echo '<li><a class="portfolio_selector"
data-group="'.strtolower(str_replace(" ", "-",
$term->name)).'"
href="#">'.$term->name.'</a><span>·</span></li>';
}else{
echo '<li><a class="portfolio_selector"
data-group="'.strtolower(str_replace(" ", "-",
$term->name)).'" href="#">'.$term->name.'</a></li>';
}
}
?>
</ul>
</div><div class="clear"></div>
<!-- Portfolio
================================================== -->
<div class="sixteen columns row teasers portfolio nopadding">
<?php if ($wp_query->have_posts()) : ?>
<?php while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?>
<?php
$custom = get_post_custom($post->ID);
$foliocatlist = get_the_term_list( $post->ID, $pcat, '', ', ', '' );
$entrycategory = get_the_term_list( $post->ID, $pcat, '', '_', '' );
$entrycategory = strip_tags($entrycategory);
$entrycategory = strtolower($entrycategory);
$entrycategory = str_replace(' ', '-', $entrycategory);
$entrycategory = str_replace('_', ' ', $entrycategory);
$entrytitle = get_the_title();
$blogimageurl = wp_get_attachment_url(
get_post_thumbnail_id($post->ID) );
if($blogimageurl==""){
$theblogimage = $templateurl.'/images/demo/460x259.jpg';
}else{
$theblogimage = aq_resize( $blogimageurl, 420,
$tune_portfoliolock, true );
}
$foliocustoms = getOptions($post->ID);
if (isset($foliocustoms["postformat_detail"])){$tune_postdetail =
$foliocustoms['postformat_detail'];}else{$tune_postdetail = 0;}
if (isset($foliocustoms["postformat_type"])){$tune_postformat =
$foliocustoms['postformat_type'];}else{$tune_postformat = 0;}
if (isset($foliocustoms["postformat_video"])){$tune_postvideo =
$foliocustoms['postformat_video'];}else{$tune_postvideo = "";}
if (isset($foliocustoms["postformat_lightbox"])){$tune_lightbox =
$foliocustoms['postformat_lightbox'];}else{$tune_lightbox = 0;}
if($tune_lightbox==1){ $lblink = $blogimageurl; } else
if($tune_lightbox==2){ $lblink =
'http://www.youtube.com/watch?v='.$tune_postvideo.'&width=720&height=435';
} else if($tune_lightbox==3){ $lblink =
'http://vimeo.com/'.$tune_postvideo.'&width=720&height=405';
}
if($tune_lightbox!=0 && $tune_postdetail==0){ $notalonemod =
"notalone"; } else { $notalonemod = ""; }
?>
<div class="four columns teaser all-group <?php echo $entrycategory ?>">
<div class="mediaholder">
<?php echo '<img src="'.$theblogimage.'" alt="" />'; ?>
<div class="cover"></div>
<?php if($tune_postdetail==0){ ?>
<a href="<?php the_permalink(); ?>"><div class="link <?php
echo $notalonemod ?>"></div></a>
<?php } ?>
<?php if($tune_lightbox!=0){ ?>
<a title="<?php echo $entrytitle ?>" href="<?php echo
$lblink ?>" data-rel="prettyPhoto[folio]"><div class="show
<?php echo $notalonemod ?>"></div></a>
<?php } ?>
</div>
<div class="topline">
<?php if($tune_postdetail==0){ ?><a href="<?php the_permalink();
?>"><?php echo $entrytitle ?></a><?php } else { ?><?php echo
$entrytitle ?><?php } ?>
</div>
<div class="subline"><?php echo $foliocatlist ?></div>
</div>
<?php endwhile; ?>
<!-- Pagination -->
<?php if(function_exists('pagination')){ pagination(); }else{
paginate_links(); } ?>
<!-- Pagination End -->
<?php else : ?>
<div class="eleven columns row alpha">
<p><?php _e('Oops, we could not find what you were looking
for...', 'tune'); ?></p>
</div>
<?php endif; ?>
<?php
$wp_query = null;
$wp_query = $temp;
wp_reset_query();
?>
<div class="clear"></div>
</div><div class="clear"></div>
<!-- Space Adjuster
================================================== -->
<div class="sixteen columns bottomadjust"></div><div class="clear"></div>
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery('.portfolio4column').tpportfolio({
row:4,
portfolioContainer:'.portfolio'
});
});
</script>
<?php get_footer(); ?>
If anyone has any suggestions on how to solve this problem. Thanks!
No comments:
Post a Comment