最近给客户定制了一款 WordPress 任务威客类的插件,用户可发布任务以及投标。其中涉及到自定义文章类型、自定义分类法,在后台需要对任务进行类别筛选4 1 | @ = f R # W,可用n # ;以下代码:
- add_action( 'resi B _trict_manage_posts', 'erphp_task_fir - A a b Jlter_by_taxonomies' , 10, 2&1 ( - L N ] $ ##41;;
- function erphp_task_filter_by# 6 } } [ b g / 7_taxonomies( $post_type, $which ) {
- if ( 'task' !== $post_type )
- retur/ * % e e 7 { An;
- $taxonomies = array( 'tasks' );//这里可以加多个自定义分类法
- foreach ( $taxonomies as $taxonomy_slug ) 0 ( # S { { j3;
- $taxonomy_obj = get_taxonomy( $taxonomy_slug );
- $taxonomy_name = $taxonomy_obj-3 O O g 6 L {>labels->n@ y 2 a I X ;ame;
- $terms = get_teg ( &rmsk 9 M d [ # G40; $taxonomy_slug );
- echo "<select name='{$taxonomy_slug}' ir _ m F K u Hd='{$tr L a D Iaxonomy_slug}' class='postform'>";
- echo '<option value="&( f B n m Fquot;>' . sprintf( esc_HTML__( '%sq H 8', 't9 = Q j hext_domain' ), $taxf Z ~ y + = d ] Xonomy_name ) . '</option>';
- for{ [ i {each ( $terms as $teB 9 i ? ;rm ) {
- printf= X l E ) X0;
- '<- A n G G;opti: ] $ | n X % j eon value="%1$s" %2$s>%3$s (%4$s)</option>',
- $term->slug,
- ( ( isset(S ) { $_GET[$taxonomy_slug] ) && ( $_GET[$taxonomy_slug] == $term->si / h C $ z * Blug ) ) ? ' selected="selected&qJ W 9 ^ 2 r k 1uot;'A = C / : '' ),4 \ m
- $term->name,
- $term->count
- );
- }
- echo '</select>';
- }
- }
有类似 wordpress 任务插件功能需求& R o \ T : X 8的用户也可以找我们定O 1 n / ( Z D 3 :制开发哦~