How can I display an archive of only one category of my custom post type?

Try this and let us know if it works: function custom_category_rewrite() { /** * Here you build an array containing the post type keys that you want * the rule to work for. */ $custom_post_types = array(‘podcast’); foreach ( $custom_post_types as $post_type ) { /** * Adds rewrite rule which will rewrite sth like http://yoursite.com/podcast/category/category-name/ … Read more

How to display posts in hyperlink with nested slugs?

This can be achieved by adding rewrite rules. First, add the query vars that will store the custom values in our rules: function wpd_family_query_var( $query_vars ) { $query_vars[] = ‘wpd_family’; $query_vars[] = ‘wpd_members’; return $query_vars; } add_filter( ‘query_vars’, ‘wpd_family_query_var’ ); Next, add the rules to capture both displaypage/family/ and displaypage/family/members/ requests: function wpd_add_family_rewrite_rules() { add_rewrite_rule( … Read more

How to remove slugs from multiple custom post types

Looks like you have your if doing the opposite of what you want. You’re returning the unaltered link if you’re on ‘furniture-type’ or ‘pop-tags’. This should work: function hf_remove_slug( $post_link, $post, $leavename ) { if((‘pop-tags’ == $post->post_type || ‘furniture-type’ == $post->post_type) && ‘publish’ == $post->post_status) { $post_link = str_replace( “https://wordpress.stackexchange.com/” . $post->post_type . “https://wordpress.stackexchange.com/”, “https://wordpress.stackexchange.com/”, … Read more

Conditional regex in add_rewrite_rule() for specific query filters & pagination

I’ve managed to workaround the problem. He’re the solution for further reference. 1) I have only 1 query var now: function return_vars( $vars ) { $vars[] = ‘filters’; return $vars; } 2) My rewrite rules changed to: add_rewrite_rule( ‘my-base/filters/([^\/]*)/([^&]*)/page/([0-9]{1,})/?’, ‘index.php?post_type=$matches[1]&filters=$matches[2]&paged=$matches[3]’, ‘top’); add_rewrite_rule( ‘my-base/filters/([^\/]*)/([^&]*)/?’, ‘index.php?post_type=$matches[1]&filters=$matches[2]’, ‘top’); Rule 1: handles pagination Rule 2: handles main page only … Read more

Why does chrome keep downloading a file instead of running the site?

What I do On receipt of WordPress files and Db install in my localhost directory (I use EasyPHP Dev server) I then install Db and change wp-config.php to connect to local db etc. Then copy .htacces to htaccess.back Edit .htaccess to point at local dir structure (in this case find “~porterp6” and replace with “wordpress2” … Read more