is_taxonomy() is not working

use is_tax() instead of is_taxonomy() as is_taxonomy() depreciated since v3.0 Refer to http://codex.wordpress.org/Function_Reference/is_tax for usage reference

Taxonomy – Exclude post format from showing on page

If you’re trying to hide a post-format on one particular page, then the function below should work. <?php // Exclude post-format from one particular page function exclude_campaigns( $query ) { // is_page() allows for page ID, page title or page slug if( $query->is_main_query() && $query->is_page( INSERT_PAGE_ID_HERE ) ) { $tax_query = array( ‘taxonomy’ => ‘post_format’, … Read more

Foreach inside foreach

First, I’d extract all the slugs of the recommended colour terms with something like this: $recommended_colours = wp_get_post_terms($post->ID, ‘recommended_colours’); $recommended_colour_slugs = array_map(function($colour) { return $colour->slug; }, $recommended_colours); … which leaves you with a $recommended_colour_slugs array that looks like this [‘blue’, ‘green’]. Then you can loop over your colour terms and use an if-else to check … Read more

`get_terms()` with `child_of` and `childless` combined

OK, so this is what I came up with: function get_childless_term_children( $parent_id, $taxonomy ) { // get all childless $terms of this $taxonomy $terms = get_terms(array( ‘taxonomy’ => $taxonomy, ‘childless’ => true, )); foreach( $terms as $key => $term ) { // remove $terms that aren’t descendants (= children) of $parent_id if( !in_array( $parent_id, get_ancestors( … Read more

the_terms characters not limiting

This is not working because the_terms() is echo-ing the output. It would make more sense to trim down the lengthy term names, instead of doing it directly on the HTML output of get_the_term_list() that’s used by get_the_terms(). That could give unvalid HTML, that could break the layout of your site. Here’s an example for the … Read more

Comma separated tax terms, with “and” before last item [duplicate]

This is how your code should look like I added some comments so you will understand its simple programming not really wordpress related. $locations = get_the_terms($post->ID, ‘location’); $locations = array_values($locations); $total_locations = count($locations); // the total start from 1 for($i = 0; $i < $total_locations; $i++) { echo $locations[$i]; // echo the location if($i < … Read more

Why does WP_Query strip colons from tag names?

The tag parameter should be the tag’s slug. If you look at your tag’s archive URL (the view link when editing the tag), it won’t have the colon in it, because that’s not a legal character in a URL. Your tag’s name can still have the colon, and you can use the URLencoded version of … Read more

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