Tag Info

New answers tagged

1

Yes, totally possible. SCENARIO 1 If you need only one taxonomy, all you need to do is to get all the term ID's of all terms assigned to the taxonomy and then pass that array of term ID's to a tax_query (Requires PHP5.4+) $term_ids = get_terms( 'TAXONOMY_NAME', [ // Array of arguments, see get_terms() 'fields' => 'ids' // Get only ...


0

If you change the paramter "number" to 2 in the line : $terms = get_terms( 'issue', 'orderby=id&order=DESC&number=1' ); You'll get the last 2 terms, so the 2 you want ?


0

Ok, thank you all for your good answers. Anyway, I need more flexibility, so I ended up not using the wp template auto-sugars... This answer is therefore not strictly related to my own original question, but I think it can help people too. I built a custom function that retrieves a set of custom posts form a specific custom taxonomy and an optional parent ...


3

Always great if someone wants to use better, more correct and more efficient ways to get things done. To achieve what you need is not difficult. WORKSFLOW: Use the usort() to create your custom sort order Use the the_posts filter to sort and return the sorted array of posts just before the loop is executed Inside the loop, all you need to do is to ...


2

If I understand the question correctly, you want to produce something like this: Sub-Item 1 Post 1 Post 2 [...] Sub Item 2 Post 1 Post 2 [...] There may be a more efficient way than what I am about to tell you, but I would try something like this: First create an array to hold your sorted posts. $sortedPosts = array(); Next, create an array for ...


0

Improved! Thks @Sisir Now, you can define more than one post type and term. You can define Allowed Post Types in ($arrayPostTypeAllowed) array, and Allowed Terms in ($arrayTermsAllowed) array. add_action('save_post', 'assign_parent_terms', 10, 2); function assign_parent_terms($post_id, $post){ $arrayPostTypeAllowed = array('product'); ...


0

This code display all posts of all categories of genre taxonomy for custom post type book. Now, For different custom post type (author, product ) you have to change Custom Post Type Name inside $arg of WP_Query(). You will get term link using get_term_link($catterm) function or you can use also get_the_term_list(). $args = array( 'number' ...


0

Good news, I figured out a way to accomplish this. Here is my solution. Taking my example above, I will walk you through what I did to get example.com/book/genre/horror to point to custom post type book, taxonomy genre and category horror. Pretty permalinks should be enabled. Go to Settings > Permalinks to enable it. Otherwise there is no point of doing ...



Top 50 recent answers are included