Get the taxonomy of the post

All I need is to find the taxonomy(ies) of post of a custom post type. It can output in any look or format and I can make it work That being the case, what you need is get_object_taxonomies() $taxonomies = get_object_taxonomies( ‘post’, ‘objects’ ); That will not give you the terms in the taxonomies. You … Read more

Categories and tags for custom post types

You need to create taxonomies specific to your post type using register_taxonomy instead of using the taxonomies argument when registering the post type. http://codex.wordpress.org/Function_Reference/register_taxonomy // categories register_taxonomy( ‘project_categories’, ‘projects’, array( ‘label’ => __( ‘Categories’ ), ‘rewrite’ => false, ‘hierarchical’ => true, ‘capabilities’ => array( ‘edit_terms’ => ‘manage_categories’ ) ) ); // tags register_taxonomy( ‘project_tags’, ‘projects’, … Read more

Wacky taxonomy in wordpress

WordPress’ terms and taxonomies are spread over three tables in the database. Those tables are wp_terms, wp_term_relationships and wp_term_taxonomy – see the codex article on Database Description for more details. The parent relationship is part of the wp_term_taxonomy table, so you should inspect the differences between your environments in this table. wp_terms does not store … Read more

Get Custom Taxonomy Terms by Date

This is the working code: // latest edition $taxonomies = array( ‘jjm_editions’ ); $args = array( ‘orderby’ => ‘ID’, ‘order’ => ‘DESC’, ‘hide_empty’ => false, ‘number’ => ‘1’ ); $terms = get_terms($taxonomies, $args); foreach ( $terms as $term ) { $term_link = get_term_link( $term ); if ( is_wp_error( $term_link ) ) { continue; } echo … Read more

WordPress implode & wp_insert_post question

The second parameter to wp_set_object_terms() takes an array, integer, or string. (array/int/string) (required) The slug or id of the term (such as category or tag IDs), will replace all existing related terms in this taxonomy. To clear or remove all terms from an object, pass an empty string or NULL. Integers are interpreted as tag … Read more

How to check if a taxonomy not exists in a plugin

You will either need to do two things Check for an empty array AND a WP_Error object Check if the taxonomy exists (which get_categories() and get_terms() already does) before your execute your code and still check for an empty array FEW NOTES TO CONSIDER get_categories() uses get_terms(), you you could use get_terms() You do not … Read more

Targeting Parent Category Pages

You can do this using custom template and template_include filter. category-parent.php and category-sub.php both are not required. One can be category.php for parent categories and for child categories, you can use custom-category-child.php as category-sub.php is reserved for default hierarchy. First create a template file in theme custom-category-child.php Then add this code to your theme functions.php … Read more

the_terms characters not limiting

This is not working because the_terms() is echo-ing the output. It would make more sense to trim down the lengthy term names, instead of doing it directly on the HTML output of get_the_term_list() that’s used by get_the_terms(). That could give unvalid HTML, that could break the layout of your site. Here’s an example for the … Read more