Firstly, don’t forget to always flush your rewrite rules by going to Settings -> Permalinks and just clicking on Save Changes
Now on your problem, it seems that you’re missing an ‘&
‘ in your query:
$new_rules['^test-directory/(.*)/(.*)'] = 'index.php?test-directory=$matches[1]&test-code=$matches[2]';
Notice the &
after $matches[1]
On the other hand, your ‘template_redirect’ action is not calling the correct function
(template_redirect
instead of my_template_redirect
)
Related Posts:
- Is there a way to list all used/unused WP templates?
- Rewrite Rules to custom template
- Pagination issue with tag.php
- Query the database after get_header() has been included
- Is it possible to create custom links inside a template?
- How to add variables to a template
- Taxonomy Parent not showing up in address bar
- Any way to insert text on page from a query results?
- How can i change email template for new user
- Enable page templates. How?
- Is it possible to override the result of get_template_part()?
- Prevent comments_template() to load comments.php
- Page editor missing Templates drop down
- Custom templates folder
- How to Rename a Template File?
- get page templates
- Preventing index.php?category_name=something from redirecting
- How to assign a class to a page with a custom template?
- Proper Javascript Implementation
- custom template for custom url
- Guest author’s post not display in author template
- Dynamically redirect page based on URL?
- How to apply a custom template for posts by default?
- how to create template path for external (include) .js file
- Is there a way to check which template file is being loaded, if it is not a page template file?
- How to remove wp_link_pages() from template
- How can I get WP to use templates in lower-level subfolder?
- how to make a home page for wordpress custom theme
- Generate Catalog Of Posts Based On Template
- Extending body classes in front- and backend
- remove query arg from url after set query
- How do I find the directory of a page template?
- Is there a way to set different post templates for parent posts and child posts in the same post type?
- Why write markup for index.php?
- How to remove the Template drop down, but keep Parent and Order
- Search results when none found – stay on page they were on
- Having trouble with Template hierarchy. I Need to create a set of pages that drill down from states to specific locations
- How can I hardcode template selection?
- Changing layout programmatically
- How to identify which template WordPress’s default search-form retrieves in my theme
- Custom taxonomy returns 404
- How to use same page template if post status other than ‘publish’?
- URL rewriting with custom user meta “/%shop_name%/gallery/%gallery%”
- How do I override the search template in a plugin?
- Is there any way to write custom HTML is some .php file and then call it wherever necessary?
- How to redirect my custom template page to content-none.php if no posts found?
- Get URL of current post but not the page number
- Is template name always same as directory name?
- Single Post Breadcrumb not linking back to Custom Post Type Index?
- Form post to WordPress page = wrong template
- How can I add text to a specific ‘Edit Page’?
- get_month_link uses what wordpress template?
- Load custom script on a single template
- Archive template limiting to 4 entries?
- Author template help. How to check if field exists in the profile?
- Retrieve query var within functions.php
- Can you use block patterns in block templates or insert them programmatically?
- WP redirect to custom login page if a user is not logged in
- Undefined get_header function
- Change default template in the block editor (Gutenberg)
- How do I create post template for different taxonomy
- Ip2location plugin in my template header?
- Import a header template from another theme
- Will placing custom templates in sub directory break any native WordPress functionality
- Archive-custome_post.php template not working
- Change “posts per page” depending on width
- How to solve this without flushing the rewrite rules for each post query the visitor triggers?
- Blog page won’t show Blog template
- How can I abstract code out of a template by using functions.php
- Make Permalink go to specific template
- WordPress function.php on ZendFramework CMS
- Site Title appearing twice on live site
- Give user option to select full post index page or excerpted index?
- how to change already posted blog to custom template wordpress?
- WordPress change title with custom dynamic
- Display articles with a different template in the home page | Solved |
- template with multiple post loops for multiple widgets [duplicate]
- Random home page at each refresh between array of page IDs
- Do not trigger page 404 on custom template
- Print different parts of content in template
- How can I pass a variable from a template to header.php of a theme
- Page Template Selector Error
- Change Page Template Based on URL Rewrite in WordPress
- I want to display all related posts for a selected tag in WordPress
- WordPress Child Theme Template auth_redirect wrapper
- Rewrite URL query string for all pages
- Need help with custom rewrite rule
- Show a custom template, no matter the page being viewed, if the user is not logged in
- printf, translation and the_author_posts_link()
- Tag Posts showing in wrong places
- Index template and Home page
- front page won’t change templates
- Including 2 Negative Is_Template Conditionals in header.php [closed]
- Add custom card template to masonry layout using Essential Grid [closed]
- Where is the general html template file?
- How to limit block activity (insertion/deletion) to inside of a Block Template on the Admin Screen?
- How to change post template
- WordPress template restored by mistake
- Create a page for each database table entries
- Unload templates; disable parent Template Parts using only “theme.json”