Changing default category on custom taxonomy
-
I would like to ask the community for assistance on changing the default category (department) to “group” for a custom taxonomy (People) made to filter out team members on a WordPress page.
To give a visual to how the People taxonomy is currently set up:
People -(category)> Department -(tags)> Executive team, Business Leadership, and Business Development.
I am trying to replace “Department” with “Groups” that also has custom tags made under it.
Below is the code that makes up the live page that I am currently working on:
‘<?php
$department = ‘executive-team’;if ( is_tax( ‘wfcf_departments’ ) ) {
$department = get_queried_object()->slug;
}$people_args = array(
‘post_type’ => WFCF_Core\People\POST_TYPE,
‘posts_per_page’ => 200,
‘tax_query’ => array(
array(
‘taxonomy’ => WFCF_Core\People\TAXONOMY,
‘field’ => ‘slug’,
‘terms’ => $department,
),
),
);if ( isset( $_GET[‘department’] ) ) {
$department = $_GET[‘department’];if ( ( ‘all’ !== $_GET[‘department’] ) ) {
$people_args[‘tax_query’][0][‘terms’] = esc_attr( $department );
} else {
unset( $people_args[‘tax_query’] );
}
}$people = new WP_Query( $people_args );
$people = wfcf_sort_people( $people, $department );
?><div class=”canvas”>
<?php if ( $people ) : ?>
<header>
<h2><?php wfcf_the_team_heading( $department ); ?></h2>
</header><div class=”frame -team”>
<?php
if ( isset( $people[‘num’] ) ) :
foreach ( $people[‘num’] as $person ) :
\WFCF_Theme\get_template_part( ‘partials/component’, ‘person’, array( ‘person’ => $person ) );
endforeach;
endif;if ( isset( $people[‘name’] ) ) :
foreach ( $people[‘name’] as $person ) :
\WFCF_Theme\get_template_part( ‘partials/component’, ‘person’, array( ‘person’ => $person ) );
endforeach;
endif;
?>
</div>
<?php endif; wp_reset_postdata(); ?>
</div>’Below is the code to filter made for the team members page, currently it is built to filter team members that are categorized under “Department” with the tags – Executive team, Business leadership, Business development, and by alphabetically (shows all teammates).
‘<?php
$selected = isset( $_GET[‘department’] ) ? $_GET[‘department’] : ‘executive’;// base URL for archive
$people_base_url = $executive_url = get_post_type_archive_link(WFCF_Core\People\POST_TYPE );// add query args
$business_leadership_url = add_query_arg( ‘department’, ‘business-leadership’, $people_base_url );
$business_development_url = add_query_arg( ‘department’, ‘business-development’, $people_base_url );
$all_url = add_query_arg( ‘department’, ‘all’, $people_base_url );
?><nav class=”team-navigation”>
-
<?php wfcf_selected_navigation( $selected, ‘executive’ ); ?>>
<?php esc_html_e( ‘Executive Team’, ‘wfcf-theme’ ); ?> -
<?php wfcf_selected_navigation( $selected, ‘business-leadership’ ); ?>>
<?php esc_html_e( ‘Business Leadership’, ‘wfcf-theme’ ); ?> -
<?php wfcf_selected_navigation( $selected, ‘business-development’ ); ?>>
<?php esc_html_e( ‘Business Development’, ‘wfcf-theme’ ); ?> -
<?php wfcf_selected_navigation( $selected, ‘all’ ); ?>>
<?php esc_html_e( ‘Alphabetical’, ‘wfcf-theme’ ); ?>
</nav>
The custom category that I am trying to replace department with is “groups”. It already exist as a taxonomy and the team members are already tagged, I am just trying to figure out how I can replace the existing “department” category with “groups” instead from the above code. Any help will be much appreciated!
-
<?php wfcf_selected_navigation( $selected, ‘executive’ ); ?>>
The topic ‘Changing default category on custom taxonomy’ is closed to new replies.