Custom post types and permalinks

I’m not really sure whats going on here – havent done too much with rewrites like this. But should this: $newRules[‘content/(.+)/(.+)/?$’] = ‘index.php?content=$matches[2]’; $newRules[‘content/(.+)/?$’] = ‘index.php?campus=$matches[1]’; Be This?: $newRules[‘content/(.+)/(.+)/(.+)/?$’] = ‘index.php?content=$matches[3]’; $newRules[‘content/(.+)/(.+)/?$’] = ‘index.php?campus=$matches[2]’; To Match: /content/peoria/new-visitor/children/ /content/peoria/connect/next-generation/children/ ?

Custom post types, taxonomies, and permalinks

Change slug in your post type arguments to products/%product_cat%, and slug in your taxonomy arguments to just products, then flush your rewrite rules. WordPress should now handle /products/my-product-cat/post-name/! Now finally, we need to help WordPress a little with generating permalinks (out of the box, it won’t recognise the permastruct tag %product_cat%): /** * Inject term … Read more

List the number of posts for each custom taxonomy and specific custom field value

The solution is: global $wpdb; $terms = get_terms(“TAXONOMY_TERM”); $count = count($terms); if ( $count > 0 ){ foreach ( $terms as $term ) { $querystr = ” SELECT count(ID) as count FROM $wpdb->posts LEFT JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id) LEFT JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id) WHERE exists ( SELECT * FROM $wpdb->postmeta WHERE … Read more