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
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
I would create 2 custom post types: People Organizations I would use the default Post post type for the articles (Assuming you’re not already using this for a blog or something else). ACF is my plugin of choice when it comes to custom fields, it allows you to create metaboxes that list all posts under … Read more
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
You could use wp_list_categories, it can be used for any taxonomy, not only categories: $args = array( ‘taxonomy’ => ‘tax’ ); wp_list_categories( $args ); See the list of arguments in the codex.
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
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
If you don’t use a plugin, then you’ll essentially have to write your own which strikes me as counter-productive. I would recommend using a plugin and figuring out how to make it work. I’ve used mfields’ Taxonomy Images to great effect. The way you access the image is certainly a little funky in some situations, … Read more
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
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
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