Page permalink conflict with Date

First of all rewrite handling can become very complicated very quickly – particularly when your desired structure conflicts with WordPress’ default behaviour. The best advice is probably to just avoid such conflicts rather than try to resolve them. With that as a premable… WordPress generates rewrite rules from various sources: from registered post types, rules … Read more

Adding meta values to permalink

Was able to get this working. Thought I would write down what we did in the hopes that it will help someone in the future (or someone can give me feedback on how to better improve it!) Registered Custom Rewrite Rules add_action(‘init’, ‘pub_rewrite_rules’); function pub_rewrite_rules() { global $wp_rewrite; $wp_rewrite->add_rewrite_tag( ‘%pubyear%’, ‘([0-9]{4})’, ‘pubyear=”); $wp_rewrite->add_rewrite_tag( “%pubmonth%’, ‘([0-9]{2})’, … Read more

Why would Numeric permalinks work, but %postname% won’t?

PROBLEM I had the same problem on Windows 7 localhost using WAMPServer and Apache 2.2.22. Any permalink structure containing the post name didn’t work. I got an error telling me the page could not be found. SOLUTION I found that, by default in this installation of Wampserver, the Apache “rewrite_module” is disabled. I enabled it … Read more

Permalink Issues by Installing WordPress in Subdirectory / Subfolder

What I generally do Install WP in sub directory. Open permalink set required permalink. Open settings->general link Remove the sub directory name from ‘Site Address (URL)’ Cut the index.php and .htaccess files from sub directory and paste them to root change code in index.php as you did. Again access settings->permalink save the form Done. You … Read more

How to modify URL structures in custom post types and taxonomies or terms

I’m not sure it’s possible, or perhaps it just may not be the best approach. Here is my reasoning: domain.com/post-type-name/taxonomy-name/term-name/post-title/ Posts can be attached to multiple terms, so in essence there could be multiple links to the same post: domain.com/post-type-name/taxonomy-name/term-name/post-title/ domain.com/post-type-name/taxonomy-name/term2-name/post-title/ domain.com/post-type-name/taxonomy2-name/term3-name/post-title/ domain.com/post-type-name/post-title/ Depending on how you got there. You will definitely be able to … Read more

Redirect old permalinks to new permalinks

WordPress should handle the 301 redirects for you automatically in this case. It doesn’t always, but it should here. Long story short, WordPress has a function, redirect_guess_404_permalink which tries to find the correct post when it encounters a 404 by using the end of the 404 url to query against the wp_posts.post_name. If it finds … Read more

How to i18n slugs for templates?

Filter template_include: add_filter( ‘template_include’, ‘prefix_translate_template’ ); function prefix_translate_template( $template ) { if ( ‘category-‘ . __( ‘news’, ‘your_textdomain’ ) . ‘.php’ === $template ) return ‘category-news.php’; return $template; } But I think templates based on slugs are not a good idea in that case.

Subdomains to pages

It’s better to use WP_Rewrite for that. add_action(‘page_rewrite_rules’,’my_page_rules’); function my_page_rules($rules){ $pageslug = ‘sample-page’; $rules[‘([^/]+)/?$’] = ‘index.php?pagename=”$pageslug”/$matches[1]’; return $rules; } add_filter( ‘page_link’, ‘sub_page_link’); function sub_page_link(){ // preg_replace here } I have found a premium plugin which uses the same mechanism to convert pages into subdomain, it uses rewrite rules and Server WildCard Configured. Hope it is … Read more

Templates for Custom Post Types and Custom Taxonomies

You have totally missed the naming convention when coming to the taxonomy archive pages, and most probably the same goes for your archive pages for your custom post types Here is how your taxonomy archive pages should look like taxonomy-{taxonomy}-{term}.php – If the taxonomy were sometax, and taxonomy’s term were someterm WordPress would look for … Read more