Articles of taxonomy

Search Posts / Pages with multiple options?

Here is what I am trying to accomplish. Need to design a website for Alcoholics Anonymous (local Chapter) to search for meetings. Need to search for multiple choices of meetings for example. Men’s meeting, on Monday, in the after noon, which is a open discussion meeting, in the city of Sylvania, Ohio. Other choices could […]

How to get the post type from a category id?

I am trying to find out the post type from a category id. Suppose that, when i am opening a category page localhost/project/foobaar/category/pen I want to know the post type to which category – pen is attached to. I have two custom post type named “book” and “copy” If category pen is associated with book, […]

Displaying the category name of a custom post type

So I have a custom query, in which I’m displaying some results posts of a custom post type called “staff”. This custom post type is linked to a custom taxonomy called “department”. I am able to display results, but I am unable to print the category that’s linked to each post. This is my code: […]

List all taxonomy terms / Show links if posts are attached, else names

I’m looking for a way to list all the terms from a custom taxonomy. Only the terms that have posts attached to it should have links to the archive page. If there are no posts attached it should only show the names. Any ideas? Thanks! <?php $taxonomy = ‘cat’; $queried_term = get_term_by( ‘slug’, get_query_var($taxonomy) ); […]

How to Retrieve a Taxonomy Term's ID?

I am trying to display a taxonomy term’s image and need the term’s ID. For some reason I am having trouble getting the ID. If I hard-code the ID in place of $term_id everything works as expected, but of course that doesn’t help in a template. For reference, my taxonomy is Organizations and each entry […]

How can I display an archive of only one category of my custom post type?

This is different from the question: How to display categories of my Custom Post Type? I have a custom post type – podcasts. I have added the taxonomy “category” as I want my ‘podcasts’ to share the ‘category’ taxonomy with my posts. I have an archive page (archive-podcasts.php) that displays the podcasts at the url […]

Return Taxonomy/Term Information with Posts (WP_Query/get_posts)

Is it possible to return taxonomy/term information for posts along with the posts themselves when querying with get_posts? I have around 150 items I am querying so I don’t want to loop and pull each individually.

How to output hierarchical taxonomy path, with only the deepest term assigned?

Let’s say we have a taxonomy that goes three levels deep, eg. A > B > C. Next, we create a post and assign it to the “C” term. In our case here, there will only ever be a single assignment; it’s the event a thing took place at. On the post’s page, I want […]

Counting number of posts in a category and its sub categories and displaying result using shortcode

I am trying to create a shortcode to display the posts count in a category. I have successfully done this using this code: // Add Shortcode to show posts count inside a category function add_count_of_posts_in_category() { $term = get_term( 7, ‘category’ ); $count = $term->count; echo $count; } add_shortcode( ‘show-posts-count’, ‘add_count_of_posts_in_category’ ); However, this means […]

Custom page template for category taxonomy

I’ve registered a category taxonomy for my custom post type: function career_create_taxonomy() { register_taxonomy( ‘career-category’, ‘careers’, array( ‘label’ => __( ‘Category’ ), ‘rewrite’ => array( ‘slug’ => ‘career’ ), ‘hierarchical’ => true, ) ); } add_action( ‘init’, ‘career_create_taxonomy’ ); I wish to create a custom page template for this category. Currently my theme is defaulting […]