How to display the rest of categories on Portfolio filterable

if your terms and their slugs are: red, blue, green, yellow. <div data-tag=”<?php echo $terms_portfolio[0]->slug; ?>” would output only the first <div data-tag=”red” if you do <?php $terms_portfolio_slugs = array(); foreach ($terms_portfolio as $tp) { $terms_portfolio_slugs[] = $tp->slug; } $terms_portfolio_csv = implode (‘, ‘,$portfoliotags); ?> <div data-tag=”<?php echo $terms_portfolio_csv?>”> your output would be all of … Read more

Assign category to front end post

I checked and it works with this: $new_post = array( ‘post_content’ => $_POST[‘post-content’], ‘post_title’ => wp_strip_all_tags( $_POST[‘post-title’] ), ‘post_type’ => ‘custom_pt’ ); note: I used a text input for the single category <input id=”input-name-value” name=”input-name-value” type=”text” /> I havent tried it with a select – option dropdown. or more than 1 category. $post_id = wp_insert_post( … Read more

Allow duplicate slugs for posts on Custom post type in different categories/taxonomy?

A simple solution would be to use a single hierarchical post type instead of a taxonomy/non-hierarchical post type combination. A hierarchical post type allows you to assign a parent post to each post. For an example you can test immediately, the built-in post post type in WordPress is non-hierarchical, the built-in page post type is … Read more

Filtering more than one term in a taxonomy in WP

You can use tax_query and use the AND condition: Reference: WP_Query under Taxonomy Parameters $args = array( ‘post_type’ => ‘post’, ‘tax_query’ => array( ‘relation’ => ‘AND’, array( ‘taxonomy’ => ‘hotels’, ‘field’ => ‘slug’, ‘terms’ => array( ‘1 Star’ ) ), array( ‘taxonomy’ => ‘location’, ‘field’ => ‘slug’, ‘terms’ => array( ‘loc1’ ) ) ) ); … Read more

Help with a query not working with custom taxonomy

Try something like this: $sotmArticle_query = new WP_Query( array( ‘post_type’ => ‘news’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘postCat’, ‘field’ => ‘slug’, ‘terms’ => ‘sotm’ ) ), ‘orderby’ => ‘date’, ‘order’ => ‘DESC’, ‘posts_per_page’ => 1 ) ); if($sotmArticle_query->have_posts()){ while($sotmArticle_query->have_posts()){ $sotmArticle_query->the_post(); ?>

get terms that have post with custom post type between 2 values

This is the finish code for this: <?php $dates_array = array(); $countries_array = array(); $term_list = array(); $current_term_list = array(); $args = array( ‘post_type’ => ‘tours’, ‘posts_per_page’ => -1 ); $loop = new WP_Query( $args ); while ( $loop->have_posts() ) : $loop->the_post(); global $post; $tour_terms = wp_get_post_terms( $post->ID, ‘tours_cats’ ); $current_term_list = array(); foreach ($tour_terms … Read more