get_terms of post->id
I think what you’re looking for is get_the_terms, which you can specify a post ID and a taxonomy to retrieve the terms attached to it.
I think what you’re looking for is get_the_terms, which you can specify a post ID and a taxonomy to retrieve the terms attached to it.
Wrap the whole thing within a form and add a submit button in it: <form method=”POST” action=””> <ul class=”filter-sub-dropdown”> … </form> Use term IDs as checkbox values instead of slugs (you’ll save a little server resources): $discipline->slug; > $discipline->term_id Then, in your functions.php file check if that form has been submitted, and change WP’s query … Read more
Found a solution. It is a WordPress builtin functionality, not a bug. Could be prevented with the ‘wp_terms_checklist_args’ filter. Below an example for use with Custom Post Type ‘product’ and Custom Taxonomy ‘product_category’: add_filter( ‘wp_terms_checklist_args’, ‘checked_not_ontop’, 1, 2 ); function checked_not_ontop( $args, $post_id ) { if ( ‘product’ == get_post_type( $post_id ) && $args[‘taxonomy’] == … Read more
Use the pre_get_posts hook to check is you are in a taxonomy term archive and change the number of posts ex: add_action(‘pre_get_posts’, ‘change_tax_num_of_posts’ ); function change_tax_num_of_posts( $wp_query ) { if( is_tax() && is_main_query()) { $wp_query->set(‘posts_per_page’, 5); } }
The problem is explained in the quote you’ve mentioned: “Default value is ‘publish’, but if the user is logged in, ‘private’ is added. And if the query is run in an admin context, protected statuses are added too. By default protected statuses are ‘future’, ‘draft’ and ‘pending’.” Ajax call is always considered to be from … Read more
I managed to solve this and I will post the answer: <?php $args = array(‘number’ => ‘1’,); $terms = get_terms(‘recipes’, $args ); foreach( $terms as $term ){ echo ‘<div class=”title”>’ . $term->name . ‘recipe</div>’; }
First of all you need the term id of hydro term, you can retrive it using get_term_by $hydro = get_term_by(‘slug’, ‘hydro’, ‘product_cat’); After that, you can use the term id as ‘parent’ argument for get_terms $hydro_children = get_terms( ‘product_cat’, array( ‘parent’ => $hydro->term_id ) ); Now you can display a list of this children: if … Read more
You should hook onto the save_post action. add_action( ‘save_post’, ‘add_video_taxonomy’ ); function add_video_taxonomy( $post_id ) { // you should check if the current user can do this, probably against publish_posts // you should also have a nonce check here as well if( get_post_meta( $post_id, ‘video_url’, true ) ) { wp_set_post_terms( $post_id, ‘video’, ‘your_custom_taxonomy_name’, true ); … Read more
I wonder if you mean something like this modified Codex example: // Fetch: $terms = get_terms( ‘category’, array( ‘include’ => array( 1, 2, 3 ), ) ); // Output: if ( ! empty( $terms ) && ! is_wp_error( $terms ) ) { $li = ”; foreach ( $terms as $term ) { $li .= sprintf( … Read more
What are the terms and taxonomy in wordpress? From WordPress.org’s Taxonomy Codex… In WordPress, a “taxonomy” is a grouping mechanism for some posts (or links or custom post types)… The names for the different groupings in a taxonomy are called terms. Using groupings of animals as an example, we might call one group “birds”, and … Read more