Your rule needs a little tweak. You also need to add id
to valid query vars.
function wpd_test_rule() {
add_rewrite_tag( '%id%', '([0-9]+)' );
add_rewrite_rule(
'^product/([0-9]+)/([^/]+)/?$',
'index.php?page_id=5&id=$matches[1]',
'top'
);
}
add_action( 'init', 'wpd_test_rule' );
Note that WordPress doesn’t put query vars in $_GET
, you’ll need to adjust your code to use get_query_var('id')
to fetch the value. I’d also consider using something more unique than id
.
Related Posts:
- How to add nofollow on all external links without plugin?
- AddToAny shortcode in the loop
- flush_rewrite_rules() not working with update_option_{$option}
- Plugin for TinyMCE to create reference to other posts
- Do shortcodes affect page indexing by search engines?
- Seo Problems in My meta Discription [closed]
- How to remove dates from existing permalinks?
- How are plugins in the WordPress plugin directory ranked?
- Adding Custom Fields for Img in Posts
- How To Ignore a Filter On Applying Filter the Content In a Function
- Shortcode display outside the div
- Pass $this to function nested in another public function of the same class
- WP get_permalink Return Wrong URL
- shortcode doesn’t work
- WordPress shortcodes & performance
- Is it possible to make shortcodes NOT case sensitive?
- Layout shop page: resize images and columns
- How to add inline css/js inside a shortcode
- How extend shortcode default values for a plugin?
- Shortcode in AJAX popup
- Looking for a solution – slightly convoluted problem
- Can I use a Shortcode output as an HTML attribute value?
- WP theme with Backbone
- Force [wordpress_social_login] shortcode to display where it is embedded [closed]
- Custom CSS for plugin form
- Show history of post revisions on front end
- Shortcode based chart plugin
- Plugin shortcodes not working in custom theme
- tag breaks shortcode output (other solutions don’t work)
- Input with spaces in Shortcode attributes overwritten by defaults
- Allow users of my plugin to define their own shortcode rather than use mine?
- qTranslate conflicts with SEO-plugins [closed]
- WordPress Shortcode to get URL Parameters $_GET[‘name’] redirects for no reason at all
- How to make a proper custom post type link
- Pagination Broken on Static Pages but Works on Blog Articles
- creating html reusable blocks via shortcodes
- add_shortcode is not working in plugin where others are working
- Single API call exposed via shortcode with params
- Making sure that a plugin’s scripts and stylesheets are included for dynamicaly loaded content
- Redirecting thousands of posts that currently have no category in their permalink when changing permalink structure to include category
- Insert content of a post into another
- How to Create a shortcode to this php function
- Use $_GET inside a shortcode print empty Array
- Render Modula Plugin Shortcode On Ajax Request
- How to add a dvi tag to a shortcode then change a generated text using jQuery
- plugin shortcode not working on ajax request call
- Shortcode not getting replaced
- How to activate a plugin on the activation of a theme?
- This WordPress plugin isn’t creating links correctly
- Yoast Force Rewrite Crashed Site [closed]
- Why is Google Search Console getting X-Robots-Tag noindex?
- IF condition based on wp_remote_get output
- shortcode not return any thing in Gutnburg
- Shortcode Attributes to Return different $_POST
- Add_rewrite_endpoint doesn’t work with post name permalink structure
- How to integrate together a website currently hosted WordPress.com and a custom web application currently hosted on Azure?
- Shortcode not working – quotes seems strange
- Get param from shortcode in plugin function
- Site shows URL instead of “meta title” after deleted few plugins (not any SEO plugin was deleted)
- Inserting shortcode in href – any ideas or workarounds?
- Get Image Having the ID [closed]
- Add the_post_thumbnail_url to a shortcode in function.php
- Form Plugin for Api Requests which is used via Shortcode
- Echo out element to another page.
- Adding a Tag Parameter / Filter to My Shortcode
- Filters on the_content with plugins, pages and shortcode
- Which is a better practice when writing shortcodes: pack lots of configuration parameters or just give an id?
- How do I fill the Home Description?
- WordPress built-in compression of images? How well does it compare to Photoshop or Shortpixel?
- How do I use a plugin’s shortcode attribute value in another function?
- Make the product page as homepage WooCommerce
- Image path in childs theme
- one url for all pages
- Is it possible to have permalinks to sub-domain pages and to root pages within one single WP instance?
- Shortcode function not showing up on mobile browser
- Get Current Post ID in WP Loop For GiveWP
- Facebook sharing image error with facebook debug
- Changing author slug for a custom role without using plugin
- Shortcode generated widget to appear on same line as heading text and button
- How to setup same post slug for different categories?
- Page takes on two different formats
- get_permalink is causing a whitescreen
- Sanitize AROUND shortcode
- Get not the full path
- Share on social media created listing after submission
- Sending post data over REST API, how to parse shortcodes in post_content?
- add_external_rule – rules deleted when visiting permalinks page
- shortcode which is introduced into entry the blog, and appears in side bar
- Space in WordPress Attribute Causing Problems
- Shortcode registered from a plugin not recognized
- Strange get_the_* behavior with php 5.4
- Unwanted Links and Spam WordPress Pages and Posts
- Strange Search Query Appearing on Google Index – “/?q=Save+Us+From+Berlusconi”
- Embedding BitBucket Code in Posting
- How to show in front End images using Visual Composer attach_images?
- Possible to change meta data single quotes to dobule quotes in yoast wordpress seo? [closed]
- URL Redirect on GoDaddy platform [closed]
- How to remove site name (https://exp.com/) from WORDPRESS site source links or file load url
- How can I get the permalink of a page on which shortcode has been used
- claim a permalink and all sublinks in plugin