OK I solved this problem:
New code:
add_action('init', 'add_test_url');
function add_test_url() {
global $wp_rewrite;
add_rewrite_tag('%v%', '(.+)');
add_rewrite_rule('^page-test/([^/]+)/?$', 'index.php?pagename=page-test&v=$matches[1]', 'top');
$wp_rewrite->flush_rules();
}
/// for debug GET value:
function console_log($content) {
echo "<!-- console_log: " . get_query_var('v') . "-->";
}
add_filter('loop_start', 'console_log', 9);
Only thing left is .htaccess redirects from old url to new url:
<IfModule mod_rewrite.c>
RewriteRule ^page-test/old_dir/([^/]+)/? page-test/$1 [R=301,L]
</IfModule>
In my case I had make a little change for the requests Ajax script and pass variable from GET request:
$get_example_v = get_query_var('v');
Related Posts:
- How to Add a Rewrite Rule for Only One Page?
- category slug and page slug same
- Need Help with Custom ModRewrite
- Is it possible to rewrite a page url Without setting the permalinks to Post Name?
- How to get current page ID outside the loop?
- Get the content of a specific page (by ID)
- How to give paged links custom title?
- featured image as background image on pages
- Show Default Editor on Blog Page ( Administration Panel )
- Create pages automatically if they don’t exist
- Can I display submenus in groups, using wp_list_pages?
- Order by menu_order and title?
- How to redirect on particular page in wordpress? [closed]
- Can I display the widget admin in the page admin?
- Internal Links to Pages in PHP?
- How to inject custom url path for page ?
- Restrict acceess of a page in backend
- wp_insert_post breaks rewrite rules
- How to display page title+link of page created by user
- Priority for Categories, Tags, Taxonomies, Posts, Pages and Custom Posts with same url
- Modify theme to get page excerpts on front page
- get_page_by_title not working when used with a variable
- How to disable Page Attributes dropdown in wp-admin
- How to make certain page templates visible to admin only
- Editing Pages that Have Already Been Published
- The entire content of my WordPress page has disappeared
- What is the proper way to get contents of a page?
- Getting child content
- Clean URL link for page without number
- How can I have two content titles?
- Get the Page Content,without generating HTML
- How can I split long posts into pages?
- Can I include Javascript/jQuery in a page?
- Adminbar Missing “Edit Page”
- conditional tags- how to use with shortcodes
- List all private pages user has access rights to read
- How to update the counter of private pages in the dashboard?
- Any Ideas for Including “More Tag” with get_pages($args)?
- Using in-build Visual Composer param types in custom param types
- Google Analytics tracking code on just one page?
- get_pages() as per custom menu order
- Pass data from one page to anothe file/page in wordpress
- Display child pages in sidebar of parent page in wordpress
- Get the Current Page Slug-Name
- Display child pages in a parent page? [closed]
- Adding a Calculator to a WordPress Page
- List all posts with the parent or grandparent of a page with a specified ID
- block a page from logged out users and redirect to homepage
- Disable ADD PDF media button on rich text editor
- invalid argument in foreach when trying to list custom post types in archive.php
- Page titles for internal classification of landing pages
- Function to incorporate an option in each Page
- WordPress page not taking precedence over server directory
- How to properly enable comments form in page template
- How do I reference the front page’s parent Page object?
- How to bypass 404 for certain pages/posts?
- Multiple Loops That Pull Pages (Child/Grandchild) While Styling the First Entry
- How do i pick the pages in 20-11 header?
- trying to add a author value in wp page links?
- Check if has pages?
- How to show page title with capitalization only as I typed in?
- Next and Previous Page links based on ‘Order’ attribute
- Create multiple pages with tables from json file
- Search anything from a Child and Sub-Pages of their Parent page
- register_rest_field only for specific page
- Update Pages ONLY from Stage to Live (not products)
- Change page width in refined magazine/mag and news theme
- How do you run code on a specific page without missing the init hook?
- Every change made by “Author” role is going to “pending review”
- Groping Pages Per Department Option
- if is_page() is not working with wp_redirect
- Display meta data attribute in user profile
- WordPress default theme cannot get full page on entry content div
- Assign Parent Page – Now 404 Error
- Create multiple custom HTML pages
- WordPress displays widgets out of whack
- Add homepage to the list of pages in the Footer Widget
- How to remove the duplicate title tags and duplicate meta descriptions?
- Two different layouts for the same post
- My page title turns into a h2 tag – What to do?
- Customise the_title in admin area
- Add pagination to search.php page
- How to turn post into pages and via versa?
- Content not displaying on page
- How do I get my page “About” to show up on my WordPress site?
- Featured Image not displaying in a page
- Display child pages on homepage template
- Pulling posts tagged with similar title name
- Filter posts by author selected in page
- Temporary download page or restrict static download page based on how the user got to the page?
- search page different results
- List Parent page with sub pages
- simple category search form returns full text – but I need excerpts
- Naming custom page templates
- How can I use Page editor for two separate templates?
- Sort the data in WordPress using get-page-by-title
- Adding a filter to wp_edit_posts_query() to prevent hierarchical display of pages
- Order pages by date
- wordpress user profile page
- In WP, Google map error initMap is not a function [closed]