Try using wp_rewrite:
add_action('init', 'flush_rewrite_rules');
function custom_add_rewrite_rules( $wp_rewrite ) {
$new_rules = array(
'archive/(\d+)' => '/?p=' . $wp_rewrite->preg_index(1)
);
$wp_rewrite->rules = $new_rules + $wp_rewrite->rules;
}
add_action('generate_rewrite_rules', 'custom_add_rewrite_rules');
Use the plugin activation hook for the flush_rewrite_rules, because you only want this to happen all the time while developing. In production this should only happen when activating your plugin.
For more about flush_rewrite_rules: flush_rewrite_rules @ WordPress.org
Related Posts:
- Moving wp-content outside of web root?
- Remove / from www.example.com/ [closed]
- Special domain for a page
- Rewrite WordPress Standard Feed URL – /feed/ to feed.xml
- wordpress.com website url structure [closed]
- hide wp-content from urls
- get_template_directory() returns wrong address on VPS
- Change dynamically URL to SEO friendly via .htaccess?
- wp-login.php ampersand in url results in 404
- Difference between esc_url() and esc_url_raw()
- Remove All Query Arg
- WordPress on a subdirectory of Laravel – WordPress pretty permalinks inner page shows laravel
- Run WordPress frontend and backend in different domains
- How to set global variable in functions.php
- Adding a hook to ‘parse_request’ so that siteurl/pagename/xyz ignores “xyz”
- How to have numeric URLs in Posts and Pages
- Why WordPress automatically removes http from the url of my website’s sub domain?
- WordPress Move to SSL How to Update Media Assets to HTTPS?
- Generate one time URL
- In Settings>>General I am missing some fields
- Prevent WordPress from automatically correcting URLs
- Adding target and _blank as it’s value to the allowedtags
- permalink for category pages and posts
- Get url from file uploaded in Media Library
- Alias ‘wp-content’ directory to something shorter (framework?)
- Allow UTF-8 characters in the user slug part of URL
- WordPress converting ../url to http://../url
- home_url(); showing current page instead of site address
- Components used in Themes and Plugins: How to get file URL?
- Can URL remain the same if migrating from Drupal?
- How to add domain security certification, in WordPress website?
- Imported thumbnails have incorrect URL
- Is it necessary to check for `content-type` in headers?
- How to allow — in category name
- Request parameters in $_GET do not match URL called
- WordPress custom search url
- The requested URL was not found only on localhost
- Allow Chinese character on post URL slug
- How can I change a media attachment URL/slug, so that I can use that slug for a page?
- Problem with utf8 link
- remove query string from homepage url
- Twitter shortlink 404 not found [closed]
- Remove Trailing Slash from Category Base and Tag Base
- How to handle this URL Structure. Keep getting “page not found”
- Custom url in wordpress
- WP URL /icons returns 403 forbidden error
- Get root folder without domain
- Is WordPress API visible from PHP file called in htaccess
- HTTP 403 Error when passing parameters to URL
- How to remove my website link when adding a link?
- How to make pages slug have priority over any category
- How to call for bloginfo inside function in functions.php?
- Website Address Keep redirect to website after migration attempt
- Random string added end of the url blog page wordpress [closed]
- Custom HTML title based on URL parameter
- Relative URLs within site
- Blog post – single.php url
- WordPress File URL Path Incorrect
- Adding more onto an esc_url [closed]
- What is the best way to revert to www version of domain name?
- How can I insert a dynamic URL in my email template?
- Block registration by URL referrer?
- Localhost access after changing URL
- Make unique url to unlock a post
- How to get previous and Next Post Url in the_post_navigation
- Changing siteurl in the database not working
- Encode URL for WhatsApp “click to chat” without loosing accented characters
- Why my WordPress website homepage automatically adding cs_preview=true query parameter to the url?
- URL redirects of webpage
- What is this extension on mu web URL?? It leads to a blank page. what is causing it/?
- Create 600 links to separate files on google drive
- Incorrect page shown
- Cant access my wordpress.org locally
- I changed the URL [closed]
- URL Structure for translated articles
- WP site homepage displays url link at beginning of each featured post
- Custome home page url
- Unable to login after changing WordPress site url
- Inject dynamic strings in urls
- Rewrite URL to get rid of wp-content etc and change URL
- Pass post title as URL parameter
- How do I make images open in a new tab by default?
- How To Change the URL of a WordPress Multisite
- How to pass parameters thru URL?
- Domain name to a page
- How to get the correct URL on my wordpress site?
- Text widget form and URL variables
- Duplicate content with the same URL, google authorship
- Making a site URL
- Avoid too long words in a post title, post content or comment but only if its not a url
- Change URL to filter posts
- Modify WordPress to not replace + (plus) characters from URLs?
- How to remove slug from url (custom post type)
- Enabling canonical links to force search engines to go to site.com rather than site.net [closed]
- Why my wordpress site URL does not begin with my domain?
- Is There a Way to Schedule URL to Content Updates?
- I changed my url and cant access my site, Help?
- Accidentally changed the url
- Standard Htaccess directives disappear by themselves
- What purpose does /embed/ URL have and how to avoid SEO problems?