Pages, Custom Posts & Custom Taxonomy defining slug structure

All of the cases you describe are handled by the post type archive, post type single, and taxonomy term archive pages that are all automatically generated (depending on arguments) when you register your post type and taxonomy. function wpd_add_custom_types() { // register fruit post type $args = array( ‘public’ => true, ‘label’ => ‘Fruit’, ‘has_archive’ … Read more

Multiple post types in archives (filter?)

Try this: function sw_custom_post_type_includes($query) { $post_types = array(‘post’,’custom1′,’custom2′,’custom3′); if ( ! is_archive() && ! in_array( get_post_type(), $post_types ) ) return $query; $query->set( ‘post_type’, $post_types ); return $query; } add_filter(‘pre_get_posts’, ‘sw_custom_post_type_includes’);

Must permalinks always point to single post pages?

There are two hooks named ‘pre_post_link’ and ‘post_link’. Their first argument – which you can change – is the permalink. So … add_filter( ‘pre_post_link’, ‘wpse_42406_change_permalink’, 10, 2 ); function wpse_42406_change_permalink( $permalink, $post ) { // change the permalink, let it point to an archive etc. return $permalink; } … will change the output. In your … Read more

Custom post type tag archives don’t work for basic loop?

Down the rabbit hole….. I found a fix. From this post Custom Post Type Archives by Date and Taxonomy Which let me to this trac ticket http://core.trac.wordpress.org/ticket/14589 and the following function post_type_tags_fix($request) { if ( isset($request[‘tag’]) && !isset($request[‘post_type’]) ) $request[‘post_type’] = ‘any’; return $request; } add_filter(‘request’, ‘post_type_tags_fix’); Maybe this didn’t make it into 3.1?

Permalinks for WooCommerce Categories and Subcategories

I was able to resolve this with the following code which generates rewrite_rules for each subcategory, which is preferred during matching since it’s more specific: function wpse_291143_generate_taxonomy_rewrite_rules( $wp_rewrite ) { global $wp_rewrite; $base = “shop”; $rules = array(); $terms = get_terms( array( ‘taxonomy’ => ‘product_cat’, ‘hide_empty’ => false )); foreach($terms as $term) { $term_children = … Read more

Show scheduled posts in archive page

Keep things simple – leave your archive templates alone and place this in your functions.php; add_action( ‘pre_get_posts’, function ( $wp_query ) { global $wp_post_statuses; if ( ! empty( $wp_post_statuses[‘future’] ) && ! is_admin() && $wp_query->is_main_query() && ( $wp_query->is_date() || $wp_query->is_single() ) ) { $wp_post_statuses[‘future’]->public = true; } }); Essentially, it says; If we’re on a … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)