Nice URLs for a Custom Post Type List with a Shared Custom Taxonomy?

For the first preference, you’d need to filter in additional rewrite rules like so; function __extra_country_rewrite_rules( $rules ) { global $wp_rewrite; if ( !isset( $wp_rewrite ) ) $wp_rewrite = new WP_Rewrite; $m1 = $wp_rewrite->preg_index(1); // preg match backreferences $m2 = $wp_rewrite->preg_index(2); $m3 = $wp_rewrite->preg_index(3); $rules[‘country/([^/]+)/([^/]+)s/feed/(feed|rdf|rss|rss2|atom)/?$’] = “index.php?country=$m1&post_type=$m2&feed=$m3”; $rules[‘country/([^/]+)/([^/]+)s/(feed|rdf|rss|rss2|atom)/?$’] = “index.php?country=$m1&post_type=$m2&feed=$m3”; $rules[‘country/([^/]+)/([^/]+)s/page/?([0-9]{1,})/?$’] = “index.php?country=$m1&post_type=$m2&paged=$m3”; $rules[‘country/([^/]+)/([^/]+)s/?$’] = … Read more

How can I set a default listing order on the admin page for a custom taxonomy? (without plugins)

You need to take a look at /core_root/wp-admin/includes/class-wp-terms-list-table.php and then add an extended class and make use of the WP_list_Table Class and documentation. basically you’re overriding the order and orderby in some custom plugin. Btw: “No Plugins” is never a good idea as plugins may show you how it works in code and therefore be … Read more

Integrating an interactive map into a WordPress custom post type

The easiest way would be to use a function which accepts a region taxonomy term as an argument, and outputs a list of posts with that term (i.e. ‘in that region’). So your template looks like: <!–nw–> <div id=”nw” class=”counties-container”> <h2>North West</h2> <p class=”nw-t”><?php my_posts_by_region(‘nw’); ?></p> </div> I’m assuming that ‘nw’ is the term name … Read more

How to assign default taxonomy to pages on ‘save_post’?

You are using wp_set_object_terms wrong, the second parameter should be the term slug or id and the 3 parameter should be the taxonomy name, so try: function set_default_object_terms( $id, $post ) { if ( ‘publish’ === $post->post_status ) { log_me (‘be in function while “publish” i pressed with this id: ‘.$id); $taxonomy_ar = get_terms( ‘property-features’ … Read more

Custom SQL Query on Custom Post Type. Order by Taxonomy?

Just looking at the term_taxonomy table, you are selecting everything correctly, but the last part: WHERE $wpdb->posts.post_type=”publications” AND $wpdb->terms.slug = %s AND $wpdb->term_taxonomy.taxonomy = ‘category’ ORDER BY $wpdb->term_taxonomy.taxonomy = ‘topics’ DESC from the post_type of publications, the terms slug of %s, and has the taxonomy of categories, but you are never selecting the taxonomy topics. … Read more