Creating custom post type posts and associating them with a post from another custom post type

Taken literally your question is about post to post relationships. Bad news — WordPress core doesn’t do post to post relationships. However there are some solutions ranging from frameworks like Posts 2 Posts to plugins like Post Connector. Stepping a bit back though, structure you are describing strongly implies grouping of posts. The mechanism for … Read more

How to get custom post type categories in an array

You can use get_terms() to retrieve the custom taxonomy terms and then build up a custom array to match the structure you want. Try this: //Get the custom taxonomy terms $taxonomies = array( ‘name’ => ‘your_custom_taxonomy’ //Edit to match your needs ); $taxonomy_terms = get_terms( $taxonomies ); //This array will store the results $taxonomy_array = … Read more

How do I get the labels from a post

As noted in the comments, Labels appears to be a taxonomy, not a post type (which is why your code snippet didn’t work. Probably the easiest way to get to do this is using get_the_term_list() like so: echo get_the_term_list( get_the_id(), ‘labels’, ”, ‘, ‘, ” ); That snippet assumes two things: That it’s used in … Read more

Custom post type name and assigning custom taxonomy

I’ve checked another option and asigned my custom taxonomy to custom post type using its name but without capitals and space. ‘postname’ works with original ‘Post Name’ So for custom post type register_post_type( ‘Post Name’, $args ); I can use register_taxonomy( ‘custom taxonomy’, array( ‘postname’ ), $args ); And it works.

Get custom term meta problem on single post type

Possible solutions: Check if there’s a prefix which you setup for the custom field (https://en.bainternet.info/tax-meta-class-faq/#comment-1107) Go to the Tax-meta-class/Tax-meta-class.php file and find the function you’re calling and debug the issue: // Tax-meta-class.php public function get_tax_meta($term_id,$key,$multi = false){ $t_id = (is_object($term_id))? $term_id->term_id: $term_id; var_dump ($t_id); // debug this $m = get_option( ‘tax_meta_’.$t_id); var_dump ($m); // debug … Read more

Get Attachment Category Name

The answer was found here: http://www.wprecipes.com/how-to-display-category-name-without-link For my purposes, I needed to define the category function and then call it by name-only inside the php echo: <?php $category = get_the_category($attachment->ID); echo ‘html goes here’; echo ”.$category[0]->cat_name.’; ?> Additionally, to help eliminate space or punctuation in the category name, it can display the slug instead: <?php … Read more

Exclude latest post from WP_Query taxonomy term loop

wp_query has the offset parameter which you can use to skip posts, e.g. $args = array( ‘post_type’ => ‘video’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘tax-video’, ‘field’ => ‘slug’, ‘terms’ => ‘t-o-t-w’, ), ), ‘posts_per_page’ => ‘8’, ‘offset’ => 1, // excludes the first post in the query ); you may just be over thinking … Read more