You can do like this, to append QUERY to permalinks (not base url):
add_filter( 'post_type_link', 'my_append_query_string', 10, 4 );
function my_append_query_string( $permalink, $post, $leavename, $sample ) {
if ( $post->post_type == 'shop' ) {
if (get_option('permalink_structure')){
$permalink = AddStringToUrl($permalink,'color=red');
}
}
return $permalink;
}
function AddStringToUrl($current_url, $string) {
return $current_url
. ( stripos($current_url, '?') === false ? '?' : '&' )
. $string;
}
Related Posts:
- Woocommerce Product Attribute Permalink doesn’t work?
- WordPress Permalink changes to question mark (?) in URL
- WooCommerce return 404 on category pages
- Redirect old permalinks to new permalinks
- Menu Link Redirect Based on Username or User ID
- Permalinks for WooCommerce Categories and Subcategories
- Remove Custom Taxonomy Slug from Permalink
- Can two products with the same name but different category produce unique URLs?
- echo post-permalink without http and www
- Add .html to Woocommerce permalinks [closed]
- Title attributes on Permalinks for posts and products
- remove product-category base but still redirect to page with same permalink
- Woocommerce subcategory 404
- Add sku to product url woocommerce [closed]
- Rewriting single post url; add_rewrite_rule problem?
- Advanced author permalinks
- WordPress 3.1 .htaccess contents keep dissappearing?
- WordPress rewrite_rules_array rule not working properly
- How do I reclaim either deleted pages or their permalinks?
- Woocommerce product permalink not working
- how to find duplicated permalinks?
- Permalinks problem woocommerce no separating slash between categories
- I want to filter my products with attributes [closed]
- replacing post ID by custom post name in url
- Auto Changing Text Case
- Post with no tag permalink problem
- Woocommerce product page 404 not found
- WordPress and Woocommerce Chinese Permalink
- Added .html to Woocommerce permalink but pagination don’t work!
- WooCommerce product permalink changed
- Permalink structure as code in back-end?
- URL to an image in a post is changing when permalink is set to custom. Can I avoid this?
- Single product link in woocomerce
- permalinks url with woocommerce
- How to get the perfect WordPress, WooCommerce, Custom Post Type pretty permalinks?
- Redirect Loops Problems
- Get current URL (permalink) without /page/{pagenum}/
- How to get pretty URLs with add_query_arg in permalinks
- How does wordpress keep track of post id when post id is not used in permalinks?
- How to add query parameters to all internal links?
- How to make draft posts or posts in review accessible via full url / slug?
- Social Media Links on homepage – within posts/post loop
- Custom rewrite rules for feeds of custom queries (query_var query strings in URL)?
- How to change the link structure of the homepage?
- woocommerce_before_calculate_totals in woocommerce 3.0
- Remove words from permalink when saving post automatically?
- How to add category to the permalink and breadcrumb?
- Add attribute / custom attribute to product in woocommerce
- Rewrite my default post URL
- Get permalink to page?
- Parent Category link to its sub categories on different page
- Permalinks: Page Not Found
- how to add rewrite rule to wordpress default post type
- Only default permalink is working mod_rewrite enabled
- Is a permastruct possible on pages?
- Custom WordPress user permalink
- How to add a variable as a tag base?
- WPML – how to get the permalinks to display also the default language
- Viewing checkout page removes fees from mini cart
- Custom permalink structure for posts in specific category
- help to change some colors (woocomerce and store locator) [closed]
- WordPress url ingore permalinks setting [closed]
- Integrating wordpress into existing site and setting up htaccess?
- wp_publish_post to saved draft, permalinks broken
- display dynamic content based on url slug on custom page
- How to generate a list of all urls
- Let me choose permalinks
- All URLs are having ‘/blog/’ appended to them.
- permalink %year% of pre-written posts to be published next year, in the mysterious future (*)
- Permalink slug no longer editable when using post_type_link filter
- Test site pages go to main site
- How to change permalinks
- How to: change permalink by category?
- Edit permalink for old posts and not show on top of RSS feed
- Page content doesn’t display when published but does when previewed as draft?
- function to set permalink to /%postname%/ on theme activation
- Change permalink structure specific category
- Add a new view on the Woocommerce account page
- How to get the full product name by ignoring custom modification on it
- How to separate an overgrown blog into sub-blogs – without breaking existing inbound links?
- Using a template file for a specific custom URL
- Change permalink structure
- Problem with get_permalink, to get page content
- How to have permalink like domain.com/%category%/%postname%/
- Permalink Increments Not Updating/Removing
- How to Remove wpautop in woocommerce includes folder class-wc-order-item.php
- WooCommerce Variation Swatches and Photos – get attribute thumbnail
- permalink of word press in htacess
- Add URL to selected post in meta box
- How to change dynamic link to relevant post
- Auto-generated pretty permalink not using title since 4.4 update
- Prevent guessing slug
- Pretty permalinks to work for lighttpd webserver?
- Customize category permalinks
- broken permalinks in responsive layout
- Show post content in two different places without redirect
- Not recognizing my custom templates in hierarchy
- Add additional URL variations for a Post
- How to use ‘blogs.dir’ as media upload instead of ‘uploads’ directory in WordPress multisite setup
- How to Set Both Category and Sub-Category Level at Root. It should also obey post rule as /category/sample-post and /sub-catgeory/sample-post?