Requested URL changes when using custom rewrite rule

this: add_rewrite_rule( ‘membership/member-profile/([^/]+)/?$’, ‘index.php?pagename=member-profile&profile=$matches[1]’, ‘top’ ); should be: add_rewrite_rule( ‘membership/member-profile/([^/]+)/?$’, ‘index.php?pagename=membership/member-profile&profile=$matches[1]’, ‘top’ ); the difference is pagename should contain the parent/child path. also- if profile isn’t a recognized query var, it needs to be added in order to be accessed: function wpse47596_query_vars( $query_vars ){ $query_vars[] = ‘profile’; return $query_vars; } add_filter( ‘query_vars’, ‘wpse47596_query_vars’ );

Format HTTP links

Actually, the extension is irrelevant. When your page is returned, WordPress is setting the content-type for the file in the headers as text/html; charset=UTF-8. This tells any consuming application that the content is HTML, not XML. You need to force WordPress to send the appropriate headers when outputting the XML. This content type is set … Read more

Using WP Rewrite to rewrite custom urls in this scenario

In your case would be something like: add_action(‘rewrite_rules_array’, ‘rewrite_rules’); function rewrite_rules($rules) { $new_rules = array( ‘product/([0-9]+)/?$’ => ‘index.php?product=$matches[1]’ ); return $rules + $new_rules; } add_action(‘query_vars’, ‘add_query_vars’); function add_query_vars($vars) { array_push($vars, ‘product’); return $vars; } add_action(‘template_redirect’, ‘custom_template_redirect’); function custom_template_redirect() { global $wp_query, $post; if (get_query_var(‘product’)) { include(YOURPLUGINDIR . ‘templates/product_template.php’); exit(); } } In product_template.php, you can … Read more

How do I Redirect a WordPress Page?

I’m sure there is a more elegant way of achieving your desires, however this method does work. Just tested it. /** * Redirect pages from array. * * @author Michael Ecklund * @author_url https://www.michaelbrentecklund.com/ * * @return void */ function redirect_pages() { // Page from => Page to $redirect_pages = array( ‘wordpresspage’ => ‘/wordpress-page’ ); … Read more

How can I emulate permalink behaviour on static pages

You need to add rewrite rules and the query_vars to fit your needs. For example. In your functions.php or plugin file: // Register a new vars to be used in the rewrite rules add_filter(‘query_vars’, ‘properties_add_query_vars’); function properties_add_query_vars( $vars) { $vars[] = “my_action”; // name of the var as seen in the URL return $vars; } … Read more

htaccess rewrite ignored

Assuming pretty permalinks are enabled in settings, WordPress does attempt to add set of rules to the .htaccess. In a nutshell their logic is to route anything that isn’t existing file/directory to WP’s index.php. After that WP is loaded and tries to interpret URL via its rewrite configuration and other data. This does not exclude … Read more

Best way to specify “article type” in URL

here’s a way to add article type with tags. First we add the taxonomy to our post add_action(‘init’, ‘article_type_init’); function article_type_init() { if (!is_taxonomy(‘article_type’)) { register_taxonomy( ‘article_type’, ‘post’, array( ‘hierarchical’ => FALSE, ‘label’ => __(‘Article Type’), ‘public’ => TRUE, ‘show_ui’ => TRUE, ‘query_var’ => ‘article-type’, ‘rewrite’ => true ) ); } } Than we hook … Read more