How do I query a taxonomy term range

You could take the query var and programatically expand the numbers between your minimum value and maximum value. Assuming http://tax.jenswedin.com/age/10,20/ is rewritten to http://tax.jenswedin.com/?age=10,20, then (pseudo code) $parts = explode(get_query_var(‘age’), ‘,’); $min_val = $parts[0]; // Should be 10 in this example $max_val = $parts[1]; // Should be 20 in this example $range = range($min_val, $max_val); … Read more

If search matches taxonomy

I only wanted to match tags in a single taxonomy, so I was able to simplify the code as follows. My taxonomy is ‘post_tag’ — just swap yours out as needed. $i = 0; $search_query = get_search_query(); $term = get_term_by( ‘name’, $search_query, ‘post_tag’ ); if( $term !== false ) { $i++; $single_result = $term; } … Read more

Add current class to queried term on taxonomy term archive

Try this instead: $terms = get_terms(‘MYTAX’); $currentterm = get_term_by( ‘slug’, get_query_var( ‘term’ ), get_query_var( ‘taxonomy’ ) ); foreach ($terms as $term) { $class = $currentterm->slug == $term->slug ? ‘live’ : ” ; echo ‘<li class=”‘. $class .'”><a href=”http://website.com/?MYTAX=’. $term->slug .'”>’ . $term->name . ‘</a></li>’; } Basically you just need to reset your $class variable back … Read more

Convert Custom Post Types to Custom Taxonomies

Here’s the solution that worked for me. I added the below code to a page template (page-test.php) and then created a page called “test,” loaded the page, and all the CPTS were converted to taxonomies. Not sure if this happened when I created the page or when I loaded it… And then I quickly deleted … Read more

Show only, when taxonomy has posts?

If you take a look at the array that get_the_terms() returns, you’ll see that it includes a “count”. If I understand your question correctly, you’re looking to find all posts with a count greater than 1 (i.e. terms that are on more than the current post). So, I think you can simply change your foreach … Read more

How do I get the current tag out of a taxonomy?

What you are looking for is get_the_terms(). You can get custom terms for the current post by using the following code: $post_tags = get_the_terms(get_the_ID(), ‘portfolio_tags_client’); if ($post_tags) { ?> <div class=”tags-div”> <h3><?php _e( ‘Tags’, ‘text-domain’ ); ?></h3> <div class=”post-tags”><?php foreach($post_tags as $tag) { echo ‘<a href=”‘.get_tag_link($tag->term_id).'” title=”‘.$tag->name.'”>’. $tag->name .'</a>’; } ?> </div> </div><?php } This … Read more

Taxonomies, restrict editing and creation of terms?

When you registered the taxonomy with register_taxonomy there is a capabilities argument. This takes, an array of the capabilities for this taxonomy. In particular: ‘manage_terms’ ‘edit_terms’ ‘delete_terms’ ‘assign_terms’ Associated with each of them should be a capability that it is required to be able to perform that action. For instance to assign_terms usually requires the … Read more

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