Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_filter(
- 'the_category',
- function ( $thelist, $separator, $parents ) {
- if ( 'brand' !== get_post_type() ) {
- return $thelist;
- }
- $brand_categories = get_the_term_list( get_the_ID(), 'brand-category', '', $separator );
- if ( empty( $brand_categories ) || is_wp_error( $brand_categories ) ) {
- return $thelist;
- }
- return $brand_categories;
- },
- 10,
- 3
- );
- add_filter(
- 'jnews_get_primary_category_filter',
- function ( $category_id, $post_id ) {
- if ( 'brand' !== get_post_type( $post_id ) ) {
- return $category_id;
- }
- $brand_categories = wp_get_post_terms(
- $post_id,
- 'brand-category',
- array(
- 'fields' => 'ids',
- )
- );
- if ( is_wp_error( $brand_categories ) || empty( $brand_categories ) ) {
- return $category_id;
- }
- return (int) $brand_categories[0];
- },
- 20,
- 2
- );
Advertisement
Add Comment
Please, Sign In to add comment