Custom Post type Query by Taxonomy

I think showposts was replaced by posts_per_page in wordpress 2.1. See pagination parameters. Also note that print_r($query) won’t return any results because $query variables is WP_Query object; you need to exceute the query. $args = array( ‘post_type’ => ‘contractors’, ‘posts_per_page’ => -1, ‘tax_query’ => array( array( ‘taxonomy’ => $taxonomy, ‘terms’ => $taxarray, ‘field’ => ‘id’ … Read more

Custom Taxonomy dont save in a frontend form for post a custom post

I think you have used wrong tax_input parameter value for wp_insert_post() function it should be array like this array( ‘taxonomy_name’ => array( ‘term’, ‘term2’, ‘term3’ ) ) as shown in the following code $my_post = array( ‘post_title’ => $title, ‘post_content’ => $content, ‘post_status’ => ‘publish’, ‘post_type’ => ‘faenas’, ‘tax_input’ => array( ‘faenas_combenef_category’ => array( $location … Read more

Custom post type meta box empty after save

As @Milo Said. Your function is ended early. Try this for save_post action. add_action( ‘save_post’, ‘mob_datebox_save’, 1, 2); function mob_datebox_save( $post, $post_id ) { // Bail if we’re doing an auto save if( defined( ‘DOING_AUTOSAVE’ ) && DOING_AUTOSAVE ) return; // if our nonce isn’t there, or we can’t verify it, bail if( !isset( $_POST[‘meta_box_nonce’] … Read more

Issue with Custom Post Type Tags

You need to use ‘taxonomies’ => array( ‘post_tag’ ) to add tags support for a custom post type, like this: function Work() { $labels = array( ‘name’ => _x( ‘Work’, ‘post type general name’ ), ‘singular_name’ => _x( ‘Work’, ‘post type singular name’ ), ‘add_new’ => _x( ‘Add New’, ‘Work’ ), ‘edit_item’ => __( ‘Edit … Read more

Add custom post type taxonomy tag to article class

Ah, solved it! <aside class=”work_item <?php $posttags = get_the_terms($post->ID, ‘type’); if ($posttags) { foreach($posttags as $tag) { echo str_replace(‘-‘,’_’,$tag->slug . ‘ ‘); } } ?>” data-type=”<?php $posttags = get_the_tags(); if ($posttags) { foreach ($posttags as $tag) { echo str_replace(‘-‘,’_’,$tag->slug . ‘ ‘); } } ?>”> had to use the get_the_terms() function