Tag Info

Hot answers tagged

3

I was pretty sure of this, but the answer is—at least for now—a definitive no. There isn't an API call for it. To double-check, I asked core developer Andrew Nacin about this on Twitter. His response: term_taxonomy_id is, for the moment, essentially private. You should likely never have it to use it. It might be worth posting a second question about ...


3

You can make use of get_post_type( $post ) to check whether a post belongs to a certain post type Inside your loop, you can do the following check while ($my_query->have_posts()) : $my_query->the_post(); if ( 'activists' == get_post_type() ) { /* Custom code for 'activists' post type. */ } else { /* Custom code for the other post types. ...


2

I would do something like OmAk suggested but I would add some fallback : $activists_thumbs = has_post_thumbnail() ? the_post_thumbnail() : 'path/img_fallback.jpg'; It's better to check if you have something before actually using it. EDIT: wp_reset_postdata() is enough (instead of wp_reset_query() )


1

Add the following to your theme's functions.php: /** * Tests if any of a post's assigned categories are descendants of target categories * * @param int|array $cats The target categories. Integer ID or array of integer IDs * @param int|object $_post The post. Omit to test the current post in the Loop or main query * @return bool True if at least 1 of ...


1

Ok, I revisited this and revised my answer.. But like I said before: the hook you are (trying) to use won't/can't work for the purpose you are aiming for, simply because its only occurrence is in class-wp-posts-list-table.php, which nomen est omen is used to show the post list, the right place should be class-wp-terms-list-table.php. 1. What you ...


1

The code has some bugs as provided above. Use the following code to also make in working in the quick edit modus: How to hook into the quick edit action? (provided by Pieter Goosen) add_action('save_post', 'assign_parent_terms'); function assign_parent_terms($post_id){ global $post; if(isset($post) && $post->post_type != 'event_type') return ...


1

You can use the count property of the taxonomy term and if it is > 1, then show the term linked to archive. // inside loop, get the terms of a custom taxonomy for the current post $terms = get_the_terms( get_the_ID(), 'your_custom_taxonomy' ); // cycle the terms and display the name, linked to archive if term count is > 1 foreach ( $terms as $term ) ...



Only top voted, non community-wiki answers of a minimum length are eligible