ポートフォリオページで、商品数を限定したい。私は 300 個の製品を持っていますが、1 ページにすべてを収めるには多すぎます。
このコードを限られた数の製品に入れました (1 ページあたり 10 製品)
'posts_per_page' => 10
そして、挿入ページの切り替え用にこのコードを配置しました(この場合は30ページ)
<!-- Pagination -->
<?php if(function_exists('pagination')){ pagination(); }else{ paginate_links(); } ?>
<!-- Pagination End -->
実際、両方のコードが機能します。掲載商品は10点限定となります。ページの下部に、30 ページのいずれかに切り替えるオプションがありました。
しかし、どの番号のページをクリックしても、常に最初の 10 個の製品を開きました。
ポートフォリオ ページ - PHP コード
<?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(); ?>
この問題を解決する方法について何か提案があれば。ありがとう!