All permalink output has filters you can use to modify it: post_link
, post_type_link
, page_link
, tag_link
, category_link
, term_link
.
A simple example with page_link
:
function wpd_append_query_string( $url, $id ) {
// check some condition and add a query string var
if( some_condition ) {
$url = add_query_arg( 'var', 1, $url );
}
return $url;
}
add_filter( 'page_link', 'wpd_append_query_string', 10, 2 );
Related Posts:
- Why is “/page/2/” not working?
- How does WordPress handle permalinks?
- Get page permalink without wpurl
- How to change ‘with_front” key from an existing custom post type?
- Why would Numeric permalinks work, but %postname% won’t?
- Passing variables through permalink structure
- Adding anchor to paginate_links + Safari anchor bug
- How to stop permalink redirects for a particular slug
- Remove subfolders from URL
- Why does WP not use relative links when linking pages?
- htaccess or redirect to cloak portion of a link?
- What is the action or filter for changing permalink in Edit Post/Page?
- WordPress Permalinks %postname% for RSS2 Feed URL
- generate custom permalink based on a custom field
- Migrating WordPress blog to New Webhosts, something is adding a # and gibberish
- How to get wordpress link to fully evaluate when coming from facebook
- Is using %postname% for permalinks really that bad for performance?
- Change author slug and functionality
- How to tranform Headlines into linkable permalinks?
- Best way to add internal link in widget
- Changing search URL to something other than “search”
- Changes to .htaccess not updating the file (old rules still take effect)
- article pages not displaying on local instance of wordpress site
- breadcrumbs & rel=”nofollow”
- Create unique alphanumeric ID on wp_insert_post
- Programatically changing post’s permalink when identical post type is published
- Permalinks not working with Vagrant
- next_posts_link URL does not include name of custom post type
- Media Gallery Images – safe to change permalink?
- Possible to remove taxonomy from permalink if uncategorized?
- Files rendering adding “.x95527” before file extension [closed]
- Custom permalink leads to index page
- How to eliminate permalink prefix in WordPress Multisite
- wp not making CPT permalink / slugs unique
- WordPress keeps giving me the wrong permalink
- Permalinks 404 error with HTTPS host
- Mirror content based on URL slug
- How to change hierarchical page permalinks to be flat
- WordPress permalink prefix
- Hierarchy of Subcategories on Permalink (bug?)
- Strange Anchor Tag Behavior (in-page links work, external pages do not) [closed]
- WordPress 3.1 .htaccess contents keep dissappearing?
- Permalink in WordPress loop outputs for each new line
- Freeze child page URLs so parent permalink changes don’t give 404s?
- New custom PHP pages are getting 404s
- How to test custom rewrite rules /permalinks?
- Add a filter to get_comments_link()
- RSS feed link on archives page not working
- Adding a prefix to the blog, but only the blog
- Order custom post type posts by custom field with pretty URL
- Show category name in the post URL only for specific categories
- post permalinks with dot in url don’t resolve to correct page template
- After cloning WP do a subdirectory, I can’t access it
- Moved site, Old links in pages still pointing to old host
- help to remove last trailing slash using add_rewrite_rule
- how to get permalink
- Protect Post Permalink From Copy
- Change permalink to attachment
- WordPress Page Not Found if Permalink Settings is Postname
- defining child page permalink
- Browsing to permalink prefix results in 404
- Shortcodes not working
- WordPress Posts forced to load as Uncategorized
- replicate url permalink after migrating to wordpress
- I need to change the attribute of the isPermaLink guid in the WordPress RSS feed – from false to true
- Shortlinks work only for logged in users
- Changing permalink for blog posts, current structure www.website.com/blog-post, change to, www.website.com/blog/blog-post
- Does wordpress take care of slug collisions?
- WordPress permalink not working on subdomain
- Fatal Error when trying to load Permalinks page on WP admin [closed]
- How to construct a dynamic rewrite rule for child pages that passes more than one query var
- Cannot publish posts or pages when I change permalink structure
- Add /blog prefix for all WordPress front end url
- Permalink structure has suddenly changed
- How to experiment with permalink structure on a select number of posts
- In a multisite, how can I get posts from one site and display their permalinks in another site?
- Remove Permalink of certain posts
- Bulk update set of URLs via SQL
- Custom permalink for one category
- How to find a page in admin based on it’s permalink
- rebuilding/ rewriting a url to make it SEO friendly
- Very strange behaviour related to htaccess and custom posts and custom posts substrings (BUG?)
- Permalink change during save of post
- Changed Permalinks settings, how do I redirect posts on Nginx?
- Choose permalink on a per-post basis?
- How to put articles under a /blog directory?
- Category-dependent custom permalink
- Pretty permalinks (again)
- How can I get WordPress CPT archives and page templates to work with prettified permalink settings?
- Passing user defined variable into get_permalink
- WordPress Archives Cause Looping
- Is there a way to add slug to home_url on this function?
- Customized author slugs not working with get_author_posts_url method
- Custom WP permalink structure
- region selection
- Redirecting From An Old Permalink Structure
- How to change my URL on intranet
- Include language variable in url
- Is it posible to translate a url prefix?
- Custom Permalink Structure For a Specific Category