Taxonomy rewrite pagination 404

While looking for a solution I got this post: Taxonomies with same slug as CPT So basically you need to add custom rewrite rules, I haven’t tested the solution but I guess it will work out for you. /* Register CPT */ function wpse_138987_post_type_filter() { register_post_type(‘filter’, array( ‘labels’ => array( ‘name’ => ‘Filter’, ‘all_items’ => … Read more

Hide echo of no categories from get_object_taxonomies

I believe that what you want is show_option_none show_option_none (string) Set the text to show when no categories are listed. Defaults to “No categories”. http://codex.wordpress.org/Template_Tags/wp_list_categories#Parameters Proof of concept: $args = array(‘include’=>123,’show_option_none’=> ”); wp_list_categories( $args );

Check category_name or taxonomy slug for a Custom Post Type?

If you’re actually using categories (and not a custom taxonomy) then your $categoryname variable needs to be the slug, not the actual name. Admittedly this Wp_Query argument name is confusing. If, however, you are using a custom taxononomy (and you’ll know if you are) then you should use ‘name-of-your-custom-tax’ => ‘slug’ instead. The codex is … Read more

Get Terms from Custom Taxonomy and Current Post

You can post the terms by using wp_get_object_terms $terms = wp_get_object_terms($post->ID, ‘departments’); if(!empty($terms)){ foreach($terms as $term){ $exampleName = $term->name; $exampleSlugs[] = $term->slug; } } Alternatively you can try to first ensure that the right taxonomy is being used: $taxonomies = get_taxonomies(); echo ‘<pre>’; print_r($taxonomies); echo ‘</pre>’; If everything is allright you’ll see an array with … Read more

How to list Custom Taxonomy

Something like this should do the job: <?php $terms = get_terms(‘YOUR-TAXONOMY’); if ( $terms ) : ?> <ul id=”portfolioFilter”> <li class=”filter” data-filter=”all”>All</li> <?php foreach ( $terms as $term ): ?> <li class=”filter” data-filter=”<?php echo $term->slug; ?>”><?php echo esc_html($term->name); ?></li> <?php endforeach; ?> </ul> <?php endif; ?>

How to get this value inside RETURN

This is more of a PHP question then a WordPress one but the answer is simple, just use PHP’s output buffer by wrapping the first code snippet eg: //create a function for the filters function get_filters(){ $terms = get_terms(‘YOUR-TAXONOMY’); if ( $terms ) { ob_start(); ?> <ul id=”portfolioFilter”> <li class=”filter” data-filter=”all”>All</li> <?php foreach ( $terms … Read more

I need to exclude from a query a category and a few custom taxonomies

Change ‘relation’ => ‘OR’ to ‘relation’ => ‘AND’ to apply both exclusions to all posts returned. It may seem counterintuitive, but a post that satisfies one of the exclusions will be included even if it doesn’t satisfy the other. EDIT From the code linked in your comment below, this is the query being generated: SELECT … Read more