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

Wp_query…a type of term a different div

The easiest way is to just create conditional statements checking for the term and wrapping it in a div of your choice. After you loop starts you could do something like: while ($list_query->have_posts()) : $list_query->the_post(); if( has_term( ‘casegoods’, ‘tag-series’ ) ) { echo ‘<div class=”left-side”>’; the_content(); echo ‘</div>’; } elseif ( has_term( ‘casegoods’, ‘rugs’ ) … Read more

Get Custom Post Child Term

Try this may be help you. $terms = get_the_terms($post->ID, ‘section’ ); echo ‘<ul>’; foreach ($terms as $term) { $term_slugs_arr[0] = $term->name; $termchildren = get_term_children( $term->term_id, ‘section’ ); foreach ( $termchildren as $child ) { $term = get_term_by( ‘id’, $child, $taxonomy_name ); echo ‘<li><a href=”‘ . get_term_link( $child, $taxonomy_name ) . ‘”>’ . $term->name . ‘</a></li>’; … Read more

Exporting Custom Taxonomy in plugin

If you use admin_init no text should be output in the file unless you have some php notice. Edit: The following code should do. <?php /** * download_custom_taxonomy_csv_154304 */ add_action(‘admin_init’, ‘download_custom_taxonomy_csv_154304’); function download_custom_taxonomy_csv_154304 () { // Check for GET request if ( isset( $_GET[‘download_ct_csv’] ) ){ header(‘Content-type: text/csv’); header(‘Content-disposition: attachment;filename=myct.csv’); // Run here your code … Read more

Grab all Custom Posts by multiple taxonomies and terms

$terms = get_terms(‘location’, array(‘orderby’ => ‘date’, ‘order’ => ‘ASC’)); foreach( $terms as $term ) { $args = array( ‘post_type’ => $post_type, ‘orderby’ => ‘date’, ‘order’ => ‘ASC’, ‘ignore_sticky_posts’ => 1, ‘post_status’ => ‘publish’, ‘posts_per_page’ => – 1, ‘tax_query’ => array( ‘relation’ => ‘AND’, array( ‘taxonomy’ => ‘organize’, ‘field’ => ‘slug’, ‘terms’ => array( ‘aba-therapist’ ) … Read more

Display what taxonomies a custom post has?

As there’s multiple Taxonomies, you will need to loop through all of the assigned taxonomies of that post type. get_object_taxonomies is the function which returns array of post type taxonomies. global $post; foreach ( get_object_taxonomies( $post ) as $tax_name ){ $taxonomy = get_taxonomy( $tax_name ); $label = $taxonomy->labels->name; the_terms( $post->ID, $tax_name, $label . ‘: ‘, … Read more