Show Two custom Post type and their posts on category page

First, I would recommend making this change in Category.php file, as archive.php is affecting tags as well as other archives according to WordPress Theme Hierarchy file system. Try adding the two queries like next: $cats = get_the_category(); $cat_id = $cats[0]->term_id; // news $args = array( ‘post_type’ => ‘news’, ‘posts_per_page’ => 5, ‘cat’ => $cat_id, ); … Read more

Keyword search limited to specific post type filtered by multiple custom taxonomies?

It’s fairly inefficient to use query_posts and I often find it’s more trouble than it’s worth. Instead, to set the post type you can just have a hidden input inside the form with name ‘post_type’ and value (in this example) ‘news’. WordPress handles the rest. Unfortunately it is not so easy with taxonomies (maybe I’ve … Read more

Is it possible to create a shortcode that will query a post based on taxonomies?

here is a simple shortcode that can handle taxonomies, post types and any other parameter that WP_Query takes: add_shortcode(‘posts’,’posts_shortcode_handler’); function posts_shortcode_handler($atts, $content){ extract(shortcode_atts(array( ‘posts_per_page’ => ‘5’, ), $atts)); global $post; $temp = $post; $posts = new WP_Query($atts); $retVal=””; if ($posts->have_posts()){ while ($posts->have_posts()){ $posts->the_post(); // these arguments will be available from inside $content $parameters = array( … Read more

Make tag cloud links consistent

How about passing the smallest and largest arguments to wp_tag_cloud() and making them both the same? <?php wp_tag_cloud( array( ‘taxonomy’ => ‘channels’, ‘smallest’ => ‘1’, ‘largest’ => ‘1’, ‘unit’ => ’em’, ) );?> Update: use get_terms() to get multiple taxonomy terms: <?php $terms = get_terms(array(‘channels’, ‘stations’)); if (is_array($terms)) : ?> <ol> <?php foreach ($terms as … Read more

Recreating the hierarchy of taxonomies for a dropdown form menu?

You can use the standard WordPress function, get the dropdown already formatted and solve both problems at once. Like so: define( ‘WP_USE_THEMES’, false ); require( ‘./wp-load.php’ ); wp_dropdown_categories( array( ‘child_of’ => 0, ‘class’ => ‘postform’, ‘depth’ => 0, ‘echo’ => 1, ‘exclude’ => ”, ‘hide_empty’ => false, ‘hide_if_empty’ => false, ‘hierarchical’ => true, ‘id’ => … Read more

Combining custom post type and post category

Must have both The following arguments array searches for the post-type-slug videos and category-slug video. It doesn’t use pagination by setting posts_per_page to -1 and only returns published posts. $args = array( ‘post_type’ => ‘videos’, ‘category_name’ => ‘video’, ‘posts_per_page’ => -1, ‘post_status’ => ‘publish’ ); Either this or that If you are trying to show … Read more

conditional statement for custom taxonomy

I’m pretty sure you shouldn’t use negation in your conditions… If you check ! is_tax… it will be true not only for other taxonomy pages, but also for singular pages, and any other… So it should look like this: <?php if ( is_tax(‘taxonomy-name’,’taxonomy-one’ ) ) {?> <div class=”test” style=”color: red”><?php the_field(‘field_name’); ?></div> <?php } elseif … Read more