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

INSERTING Data into table with placeholders

I found the answer, in the codex. I just used it’s code and adapted it, this code: $wpdb->query( $wpdb->prepare( ” INSERT INTO $wpdb->postmeta ( post_id, meta_key, meta_value ) VALUES ( %d, %s, %s ) “, 10, $metakey, $metavalue ) ); So it works now.

Showing HTML if Post is In Certain Taxonomy Term

Try using has_term(). Something like this: <?php if( has_term(‘term1’, ‘taxonomy_name’, $post) ) { ?> <img src=”http://www.site.com/wp-content/themes/site/img/stars-01.png” width=”100″ height=”21″ alt=”default”> <?php }elseif ( has_term( ‘term2’, ‘taxonomy_name’, $post) ) { ?> <img src=”http://www.site.com/wp-content/themes/site/img/stars-01.png” width=”100″ height=”21″ alt=”default”> <?php } else { ?> <img src=”http://www.site.com/wp-content/themes/site/img/stars-01.png” width=”100″ height=”21″ alt=”default”> <?php } ?> You may also want to try using shorthand … Read more