How to properly rewrite url by custom var

I’ve been trying to rewrite a shop uri, and what I have now is this code: add_filter(‘rewrite_rules_array’,’wp_insertMyRewriteRules’); add_filter(‘query_vars’,’wp_insertMyRewriteQueryVars’); add_filter(‘wp_loaded’,’flushRules’); // Remember to flush_rules() when adding rules function flushRules(){ global $wp_rewrite; $wp_rewrite->flush_rules(); } // Adding a new rule function wp_insertMyRewriteRules($rules) { $newrules = array(); $newrules[‘shop/brand/(brand)/?$’] = ‘shop.php?brand=$matches[1]’ ; //$wp_rewrite->rules = $new_rules + $wp_rewrite->rules; return $newrules + … Read more

How to improve WordPress security by hiding non public facing files?

e.g. curl -I http://ma.tt/blog/wp-config.php 200 OK The wp-config.php is not public facing file, since it currently just return blank page, so why not return 404 instead. (so will not be cached by Google) Also, for file such as readme.html, it should be hidden as it disclose your wordpress version, e.g. http://ma.tt/blog/readme.html So, currently I have … Read more

Combine Multiple Categories Into One URL Slug

I have a WordPress website with 20+ categories. To make it easier to navigate I want to decrease the categories, but at the same time keep the original categories. In other words I want to be able to query multiple categories with a category group or a virtual slug. Example categories: /category/apples/ /category/pears/ /category/bananas/ I … Read more

WordPress not respecting template hierarchy (fetches index.php instead of single.php or page.php)

I’ve encountered a strange error while developing a custom theme. After finishing editing the template for a custom post type single view, I passed onto working at the template files for pages and I ealized that WordPress was actually pointing to index.php template file rather than page.php in my theme for generating the page appearance. … Read more

Possible to change the slug of default post type?

I have custom post types on my wordpress site and I’ve set the slugs to say “/blog/{post_type}/{post_title}”. I’m using the default post type as a “notes” section, so I want that slug to be “/blog/notes/{post_title}”. Is this possible? 2 Answers 2 There are many »default post types« like post, page or even nav_menu_item. If you … Read more

When is it a good idea to build a permalink structure from scratch?

Is it a good idea to design a permalink structure from scratch? The requirements to the structure are as follows: Pages to be referenced by their structure (example.com/grandparent-slug/parent-slug/child-slug). Posts to be referenced by category and date (example.com/category-slug/2013/07/my-post-slug). Archives only available by category (example.com/category-slug), by category and year (example.com/category-slug/2013) by category, year and month (example.com/category-slug/2013/07) and … Read more

add_rewrite_rule() to route to file other than index.php

add_rewrite_rule( ‘^invite/([^/]+)’, ‘index.php?pagename=invite&iid=$matches[1]’, ‘top’ ); The “internal” rewrite rule above will route traffic through index.php using the pagename argument (which necessitates having a page with slug invite). I want to direct routing to invite.php (which will render an ICS calendar file and force download). I looked into the below implementation, however, this appears to directly … Read more

Remove Author Slug & Replace With Username

I reviewed all related questions but none tackle this exactly so I’m posting the question in hopes the pro’s know how to handle this. I would like to change the author slug to remove the term /author/ completely like this; currently example.com/author/username want example.com/username Moreover I’d like all posts related to an author to look … Read more

Is it possible to rewrite URLs in this situation?

I am using a fantastic plugin called Query Multiple Taxonomies which provides a widget to “drill down” by category / tag and other custom taxonomies you may have. The site is livetonom.com. The widget (on the sidebar) gives URLS ending: /?category_name=restaurants&locations=london Is it possible to rewrite that to something like: /restaurants/london I tried using a … Read more