下面我有我的自定义分类模板,到目前为止它工作正常。
<?php
/*
Template Name: Performer List Page
*/
get_header(); ?>
<?php
// if show all is set
$sortby=$_GET['sortby'];
if( isset($_GET['showall']) || isset($sortby) ):
$args = array( 'hide_empty' => 0 );
else:
// else show paged
$page = ( get_query_var('paged') ) ? get_query_var( 'paged' ) : 1;
global $framework_opt,$post; $number_of_performers = $framework_opt['performers_per_page'];
$orderby = 'date';
$order = isset( $_REQUEST['order'] ) ? trim( $_REQUEST['order'] ) : null;
if(isset($_GET['order']) && !empty($_GET['order'])) {
switch($order)
{
case 'alphabetically' : $orderby = 'title';
break;
case 'popularity' : $orderby = 'count';
break;
/*
case 'female' : $meta = 'gazi_female';
break;
case 'male' : $meta = 'gazi_male';
break;
*/
default : $orderby = 'date';
break;
}
}
// number of tags to show per-page
$per_page = $number_of_performers ;
$offset = ( $page-1 ) * $per_page;
$args = array( 'orderby' => $orderby, 'number' => $per_page, 'meta_key' => $meta, 'offset' => $offset, 'hide_empty' => 0 );
endif;
$taxonomy = 'performer';
$count_performers = wp_count_terms( $taxonomy, $offset );
$tax_terms = get_terms( $taxonomy, $args );
?>
<aside class="sidebar pull-left">
<p class="sidebar-title"><?php _e( 'SEARCH BY LETTER', 'gazi' ); ?></p>
<div class="letter-search clearfix">
<span class="letter"><a href="<?php the_permalink() ?>?sortby=A">A</a></span>
<span class="letter"><a href="<?php the_permalink() ?>?sortby=B">B</a></span>
<span class="letter"><a href="<?php the_permalink() ?>?sortby=C">C</a></span>
<span class="letter" style="width:40%"><a href="<?php the_permalink() ?>?showall=true"><?php _e( 'All', 'gazi' ); ?></a></span>
<span class="letter" style="width:40%"><a href="<?php the_permalink() ?>"><?php _e( 'Reset', 'gazi' ); ?></a></span>
</div>
<!--<p class="sidebar-title"><?php _e( 'QUICK SEARCH', 'gazi' ); ?></p>
<form class="frm-search-tag has-title" action="<?php echo home_url( '/' ); ?>" method="get">
<input type="text" placeholder="Search name" name="s" value="" />
<button type="submit"><span class="ico ico-search"></span>
<select class="search_tools" style="display:none;" name="taxonomy" >
<option value="performer">Videos</option>
<option value="gallery">Photos</option>
</select>
</button>
</form>-->
<div style="height: 5px;"></div>
<?php get_template_part( 'templates/sidebars/performer-sidebar', get_post_format() ); ?>
</aside>
<section class="main-section pull-left">
<div class="page-title with-sorter clearfix">
<h1><?php the_title(); ?></h1>
<div class="info hidden-mobile">
<p>
<?php echo $count_performers; ?><?php _e( 'Performers', 'gazi' ); ?> <span class="ico ico-tv"></span>
</p>
<div class="sorter">
<div class="dropdown-container">
<ul class="flyout-menu flyout-menu-right">
<li>
<button class="dropdown-toggle" type="button" data-action="dropdown-toggle" data-target="#sorter-dropdown">SORT</button>
<div class="flyout-menu-content" id="sorter-dropdown">
<ul class="flyout-menu-items">
<li>
<a href="<?php the_permalink() ?>?order=alphabetically"><?php _e( 'Alphabetically', 'gazi' ); ?></a> </li>
<li>
<a href="<?php the_permalink() ?>?order=popularity"><?php _e( 'Popularity', 'gazi' ); ?></a> </li>
</ul>
</div>
</li>
</ul>
</div></div> </div>
<div class="info visible-mobile clearfix">
<button class="btn-pd btn-pd-primary pull-left" style="margin-right: 0;" data-action="scroll-to" data-target="#letter-search">A-Z</button>
<p style="float:right">
<?php echo $wp_query->found_posts; ?> <?php _e( 'Performers', 'gazi' ); ?> <span class="ico ico-tv"></span></p>
</div></div>
<div id="performer-list" class="list-view">
<div id="performer-thumbs" class="performer-listing clearfix">
<div class="items">
<?php foreach ($tax_terms as $cat) : ?>
<?php
$flag = 0;
if( $sortby == substr( $cat->name, 0, 1 ) || $sortby=='' ) { $flag = 1;}
if ($flag=='1'){
?>
<article class="performer-item">
<a class="outline" href="<?php echo get_term_link($cat->slug, 'performer'); ?>" title="<?php echo $cat->name; ?>">
<?php $performer_image = z_taxonomy_image_url($cat->term_id); if(!empty($performer_image)) : ?>
<img src="<?php bloginfo('template_directory'); ?>/gazi/css/images/1pixel.gif" data-src="<?php echo z_taxonomy_image_url($cat->term_id,NULL, array(180, 240)); ?>" alt="<?php echo $cat->name; ?>" />
<noscript><img src="<?php echo z_taxonomy_image_url($cat->term_id,NULL, array(180, 240)); ?>" alt="<?php echo $cat->name; ?>" /></noscript>
<?php else : ?>
<img src="<?php bloginfo('template_directory'); ?>/gazi/css/images/1pixel.gif" data-src="<?php bloginfo('template_directory'); ?>/gazi/css/images/no-img-women.jpg" alt="<?php echo $cat->name; ?>" />
<noscript><img src="<?php bloginfo('template_directory'); ?>/gazi/css/images/no-img-women.jpg" alt="<?php echo $cat->name; ?>" /></noscript>
<?php endif; ?>
<span class="performer-name"><?php echo $cat->name; ?></span>
<span class="performer-videos hidden-mobile">
<span class="count"><?php echo $cat->count; ?></span>
<span class="txt"><?php _e( 'VIDEOS', 'gazi' ); ?></span>
</span>
</a>
<div class="performer-item-footer visible-mobile">
<span class="ico ico-take"></span> <?php echo $cat->count; ?> <?php _e( 'VIDEOS', 'gazi' ); ?> </div>
</article>
<?php } ?>
<?php endforeach; ?>
</div>
</div>
<?php
if( isset($_GET['showall']) || isset($sortby)):
echo '';
else:
// showall is set, show link to get back to paged mode
$total_terms = wp_count_terms( 'performer' );
$pages = ceil($total_terms/$per_page);
// if there's more than one page
if( $pages > 1 ):
echo '<div class="pager"><div class="paginator" id="performer_paginator">';
for ($pagecount=1; $pagecount <= $pages; $pagecount++):
echo '<a class="page" href="'.get_permalink().'page/'.$pagecount.'/"><span>'.$pagecount.'</span></a>';
endfor;
// link to show all
echo '<a class="page" href="'.get_permalink().'?showall=true">ALL</a>';
echo '</div>';
endif;
endif;
?>
</div>
<div id="letter-search" class="visible-mobile">
<div class="section-title with-sorter clearfix" style="margin-bottom: 4px;">
<p class="title">Letters Search</p>
<div class="info">
<button class="btn-pd btn-pd-sm btn-pd-primary pull-right" data-action="scroll-to" data-target="#performer-thumbs"><span class="ico ico-grid"></span></button>
</div>
</div>
<div class="letter-search clearfix">
<span class="letter"><a href="<?php the_permalink() ?>?sortby=A">A</a></span>
<span class="letter"><a href="<?php the_permalink() ?>?sortby=B">B</a></span>
<span class="letter"><a href="<?php the_permalink() ?>?sortby=C">C</a></span>
</div>
</div>
<?php get_template_part( 'templates/advertisements_bottom', get_post_format() ); ?>
</section>
<?php get_footer(); ?>
如果您看到我为受欢迎程度添加了一个订购菜单,并且此列表的视频计数有效,但在订购代码下您将看到:
/*
case 'female' : $meta = 'gazi_female';
break;
case 'male' : $meta = 'gazi_male';
break;
*/
所以我想使用上面的自定义字段将表演者按男性和女性分开。任何知道如何完成此模板的人?谢谢