Show Custom Taxonomy Categories, Listing of Posts, and Single Post via AJAX
Show Custom Taxonomy Categories, Listing of Posts, and Single Post via AJAX
Show Custom Taxonomy Categories, Listing of Posts, and Single Post via AJAX
What I’m trying to do (for instance): list all the concerts which belong to artists of the “pop” genre. You can do it in two steps: // 1. Get all the pop artist IDs $artist_ids = get_posts( array( ‘fields’ => ‘ids’, ‘post_type’ => ‘artist’, ‘genre’ => ‘pop’ ) ); // 2. Get all the concerts … Read more
WordPress parses incoming URLs with a list of regular expressions, the rewrite rules. The first regex that matches the URL “wins”, and determines what kind of query will be executed. You can see the rewrite rules and play with different URLs with my Rewrite analyzer plugin. Whether or not pages take priority over other rules … Read more
You can use get_terms to get the list of all terms associated with a taxonomy. Once you have all the separate terms, you can use $term->name to display the name of the term and $term->count to retrieve the amount of posts inside that specific term. Here is a slightly modified version of the code found … Read more
You would use the save_post hook, in your hooked function use wp_insert_term as described here: http://codex.wordpress.org/Function_Reference/wp_insert_term Then use wp_set_object_terms on the post to assignt he taxonomy term you just created as follows: http://codex.wordpress.org/Function_Reference/wp_set_object_terms for example: function my_save($post_id) { wp_insert_term( ‘bannanapost’, ‘fruit’); wp_set_object_terms( $post_id, ‘bannanapost’, ‘fruit’, true ) } add_action(‘save_post’,’my_save’); The above code, placed in functions.php … Read more
You can try the following code. function custom_post_type_title ( $post_id ) { global $wpdb; if ( get_post_type( $post_id ) == ‘cars’ ) { $engine=”, “.get_post_meta($post_id, ‘Engine’, true).’l’; $terms = wp_get_object_terms($post_id, ‘brand’); $abrand= ‘ ‘.$terms[0]->name; $amodel=” “.$terms[1]->name; $title = $post_id.$abrand.$amodel.$engine; $where = array( ‘ID’ => $post_id ); $wpdb->update( $wpdb->posts, array( ‘post_title’ => $title ), $where ); … Read more
I figured it out! First step, is to sort the posts by taxonomy (so that they’re grouped together). This will give a list of posts that can be paginated (just like a regular list). The trick now, is to add a (taxonomy) heading above related posts. So, for each pass of the loop Im looking … Read more
This is just a concept which you can try. By default, you cannot sort within the loop. You have, according to my knowledge, have two choices Create two loops and merging them. This, however, I would not recommend. Pagination and offsets are a nightmare if you are not completely comfortable with it Run your loop … Read more
Add Custom Taxonomy Tags to Your WordPress Permalinks What you wish to do is have your taxonomy available to use within the Permalink structure e.g. /%actor%/%postname% First you write your taxonomomy as you have already done, but you require additional fields: add_action(‘init’, ‘add_actor_taxonomy’); function add_actor_taxonomy() { if (!is_taxonomy(‘actor’)) { register_taxonomy( ‘actor’, ‘post’, array( ‘hierarchical’ => … Read more
I come to this post as i was looking for the code. But the marked answer not working for me anymore. I have wrote a function to get the deepest level category assigned to a post. function post_deepest_level_cat($post_categories) { foreach ($post_categories as $category) { $cat_ids[] = $category->term_id; } $tree_args = array( ‘current_category’ => $cat_ids, ‘depth’ … Read more