URL Rewrite + Page + Custom Post Type = Unusual Redirect

You should try setting ‘slug’ ( in the ‘rewrite’ parameter/option) to ‘our-firm/shareholders’, just like the structure you have set in the add_rewrite_rule() function. The first parameter of add_rewrite_rule() and the ‘rewrite’ setting of the custom post type must be equal in order to get the rewritting actually working. So, in case you choose coding the … Read more

permastruct for custom post type not working in one of four cases

You’re currently placing your rewrite rules in the global scope, which means they execute as soon as your file is loaded, which may be too early. Instead try adding them on the init hook, or rewriting them to use the generate_rewrite_rules filter instead, e.g.: add_action(‘generate_rewrite_rules’, ‘themes_dir_add_rewrites’); function themes_dir_add_rewrites() { $theme_name = next(explode(‘/themes/’, get_stylesheet_directory())); global $wp_rewrite; … Read more

How to change author base without front

This is the best solution I have come up with but I welcome better ways: function change_author_permalinks() { global $wp_rewrite; $wp_rewrite->author_base=”connect/member”; $wp_rewrite->author_structure = “https://wordpress.stackexchange.com/” . $wp_rewrite->author_base . ‘/%author%’; add_rewrite_rule(‘connect/member/([^/]+)/?$’, ‘index.php?author_name=$matches[1]’, ‘top’); } add_action(‘init’,’change_author_permalinks’);

+ Character in permalink

Per the OP, here is their answer which I separated from the question: I have found a solution for it myself, I’ve used the Custom Permalinks plugin and edited how the special characters are saved in the database. For the people who want to use this, change: add_post_meta( $id, ‘custom_permalink’, str_replace(‘%2F’, “https://wordpress.stackexchange.com/”, urlencode(ltrim(stripcslashes($_REQUEST[‘custom_permalink’]),”https://wordpress.stackexchange.com/”))) ); to … Read more

Passing variables through permalink structure

Solved it! // Register the variables that will be used as parameters on the url function add_my_var($public_query_vars) { $public_query_vars[] = ‘extra_slug’; return $public_query_vars; } add_filter(‘query_vars’, ‘add_my_var’); // Build the rewrite rules, for the extra parameter function do_rewrite() { add_rewrite_rule(‘(accommodation)/[/]?([^/]*)$’, ‘index.php?pagename=accommodation&extra_slug=$matches[2]’,’top’); } add_action(‘init’, ‘do_rewrite’); // The parameter is now accessible get_query_var(‘extra_slug’)

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

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

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