Need to make a php file inside theme accessible via url

Ok here is a test working solution: <?php /* Plugin Name: wpse26719 Plugin URI: http://en.bainternet.info Description: Need to make a php file inside theme accessible via url Version: 1.0 Author: Bainternet Author URI: http://en.bainternet.info */ // Register a URL that will set this variable to true add_action(‘generate_rewrite_rules’, ‘wpse26719_rw’); function wpse26719_rw($wp_rewrite) { $newrules = array(); $new_rules[‘^adserver.js.php$’] … Read more

Add .html extension to custom post type taxonomies

I’ve tested your first attempt with using a rewrite rule it works add_action(‘init’, ‘add_html_ext_to_custom_post_type_taxonomies’); function add_html_ext_to_custom_post_type_taxonomies() { add_rewrite_rule(‘^product_cat/(.+)\.html’, ‘index.php?product_cat=$matches[1]’, ‘top’); } but you have _ not – had you noticed this as you give your example as www.mydomain.com/product-category/product-category-name.html If its not a mistake it might be you have another rule conflicting with it? and also … Read more

unexpected problem in url rewrite

first, you need to add your custom_gallery_id to query vars if you haven’t already: add_filter( ‘query_vars’, ‘wpse26388_query_vars’ ); function wpse26388_query_vars( $query_vars ){ $query_vars[] = ‘custom_gallery_id’; return $query_vars; } for your rewrite rule, you need to load a WordPress object– a page, a category, etc., and all internal rewrites must point to index.php. if topic, place, … Read more

How to rewrite custom post type URL for multiple depths instead of one specific depth

After testing countless different structures i came up with this. It’s manual work specifying each category but gives me more control. If someone comes up with a better solution, please let me know. function mmp_rewrite_rules($rules) { //Product structure $newRules[‘product/(.+)/(.+)/(.+)/(.+)/?$’] = ‘index.php?products=$matches[4]’; //The above structure only works of the postname is the 5th uri segment //It’s … Read more

Change the custom post type permalink

You can use rewrite arg in register_post_type. You can have custom post type name different then rewrite slug. For example here is the sample code with custom post type project and it shows pages with http://shaowtriger.com/brands/naim/ Notice rewrite in $args add_action( ‘init’, ‘codex_brand_init’ ); function codex_brand_init() { $labels = array( ‘name’ => _x( ‘Brands’, ‘post … Read more

Remove base slug in CPT & CT, use CT in permalink

I copied your code as-is above, pasted it into the twentysixteen theme, and changed just the post type rewrite slug from review/%brand% to %brand%. This resulted in both the term archive and review posts having your desired URL structure and successfully displaying. Now the bad news is that the rewrite rules generated for the taxonomy … Read more

Many to Many Taxonomies or rewrite rules?

With reservations, sure, you can do what you want with this code: add_action(‘init’, ‘wpse_61376_rewrites’); function wpse_61376_rewrites() { add_rewrite_rule(‘^([^/]*)/([^/]*)/?$’,’index.php?category=$matches[1]&location=$matches[2]’,’top’); } Then go to Settings → Permalinks in wp-admin and click “Save Changes” to flush your rewrites and activate this rule. Reservations The problem about not having a prefix is that any permalink with two “sections” (site.com/section-1/section-2/) … Read more

Pros and cons of using [taxonomy name] in place of [category name]?

For the SEO part you might get better answers on the Pro Webmasters Stack Exchange. I will focus on the performance. From your example I assume your permalink structure was %category%/%postname%/. Because of the way WordPress parses the incoming URL, this will result in verbose page rules, which means that each page (not post) you … Read more