How to get name of custom taxonomy

I believe you are talking about when the archive.php is used as a taxonomy page. If so, you will first need to check if the current page being viewed is actually a taxonomy page. If you don’t do this check, you will get errors on pages that are not taxonomy pages, for instance date archive … Read more

Conditional Logic Based on Custom Taxonomy

@Milo was absolutely correct…the issue was that I wasn’t getting a string to compare. The solution actually came from here. What this ultimately looked like in my scenario: <?php if(has_term(‘dining-1’, ‘page_category’, $post->ID)){ get_template_part(‘sidebar’, ‘dining-one’); } elseif(has_term(‘dining-2’, ‘page_category’, $post->ID)){ //etc. } ?>

How to show/hide a meta box using categories, with a different post type

Instead of if (is_admin()) add_action(‘admin_menu’, ‘add_custom_box’); use add_action(‘add_meta_boxes’, ‘add_custom_box’); The ‘add_meta_boxes’ hook is the correct one to add meta boxes. Other than that, as you mentioned correctly change the ‘post’ to ‘$my-custom-post-type’ and register the category taxonomy for that post type: register_taxonomy_for_object_type( ‘category’, ‘$my-custom-post-type’ )

Broken paths on taxonomies after changing permalink to post name

I added a rewrite rule manually. add_rewrite_rule(‘^bar([^/]+)(/[0-9]+)?/?$’,’index.php?bar=$matches[1]’,’top’); right after add_action(‘init’, ‘register_taxonomy_bar’); in functions.php. But WordPress is SERIOUSLY DENSE in translating /bar/foo/ to barfoo?bar=foo and I don’t know how to get around this nonsensical “barfoo” in the path. I also have no idea what it’ll do to paging. Also this has to be defined for each … Read more

How do you search for a post by custom taxonomy?

For the record I found an answer to this question in the end – I needed to use a meta query rather than a taxonomy query. The correct code ended up being this: $relatedBlogPostArgs = array( ‘post_type’ => ‘post’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => 1, ‘order’ => ‘DESC’, ‘orderby’ => ‘date’, ‘meta_query’ => array( array( … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)