single-{post_type}.php not working

according to your code, your cpt is “event”. You will either need to change the your php to single-event.php or change this line: register_post_type(‘event’, $args); to register_post_type(‘events’, $args); Usually they are the plural so the 2nd option is a better choice. With that being said, I always recommend adding namespace to avoid conflicts. Especially in … Read more

Search Query for Multiple Terms In Same Taxonomy

You need to make only one change in the form, change the first line to: <select name=”property_type[]” class=”form-control” multiple> Name of the field has to include [] to be considered as an array when it arrives on the server side. In the query string it will be listed as: property_type[]=condo&property_type[]=duplex And, on server side, when … Read more

Count Number of Posts in Taxonomy Term in Last 24 Hours

You can create a custom WP_Query and count its result. $wp_query = new WP_Query([ ‘tax_query’ => [ [ ‘taxonomy’ => ‘news’, ‘terms’ => $term_name, ‘fields’ => ‘name’ ] ], ‘date_query’ => [ [ ‘after’ => ’24 hours ago’ ] ] ]); $number_of_posts = $wp_query->found_posts; Edit I removed posts_per_page argument, as @birgire suggests, that found_posts offers … Read more

How do I return all terms from multiple taxonomies?

You have all sorts of fun questions today! There is also a WP_Term_Query available in WordPress. Here is some info on it as well as what parameters you can pass it. https://developer.wordpress.org/reference/classes/WP_Term_Query/__construct/ $term_args = array( ‘taxonomy’ => array(‘tax_one’, ‘tax_two’, ‘tax_six’), ‘hide_empty’ => false, ‘fields’ => ‘all’, ‘count’ => true, ); $term_query = new WP_Term_Query($term_args); foreach … Read more

How to add custom taxonomy in custom post type permalink?

Solution would be a little tricky but you’re on the right path. You need to register taxonomy and post type with dynamic rewrite: function wpse346452_cpt() { register_taxonomy( ‘campaign’, ‘asset’, array( ‘label’ => ‘Campaing’ ) ); register_post_type( ‘asset’, array( ‘public’ => true, ‘label’ => ‘Asset’, ‘rewrite’ => array( ‘slug’ => ‘%campaign_name%’, ), ) ); } add_action( … Read more

Custom Taxonomy Not Showing in Front-End When Outputting a Custom Post Type with WP_Query()

From your explanation above I understood that you want to show custom taxonomy you have registered for that post type. the_category(); fetches the default category that comes with the default post. For rendering custom taxonomy you need to add something like this: $terms = get_the_terms( $post->ID , ‘your custom taxonomy slug’ ); foreach ( $terms … Read more

get_terms() duplicate first term of a custom taxonomy

I think you want to show list of the category links right? but you are echo list inside the for-each loop. you have to write that outside of the loop. foreach ($terms as $term) { $term_list .= ‘<a class=”related-market btn btn-outline-secondary” href=”‘ . esc_url(get_term_link($term)) . ‘”>’ . $term->name . ‘</a>’; } echo $term_list; Also don’t … Read more