All of the API functions that generate links have filters to let you alter the output. Here’s a quick example that covers most of them:
function wpd_endpoint_links( $url ){
if( isset( $_COOKIE['lang'] ) ){
$url = $url . $_COOKIE['lang'] . "https://wordpress.stackexchange.com/";
}
return $url;
}
add_filter( 'post_link', 'wpd_endpoint_links' );
add_filter( 'page_link', 'wpd_endpoint_links' );
add_filter( 'post_type_link', 'wpd_endpoint_links' );
add_filter( 'attachment_link', 'wpd_endpoint_links' );
add_filter( 'term_link', 'wpd_endpoint_links' );
add_filter( 'author_link', 'wpd_endpoint_links' );
add_filter( 'post_type_archive_link', 'wpd_endpoint_links' );
add_filter( 'day_link', 'wpd_endpoint_links' );
add_filter( 'month_link', 'wpd_endpoint_links' );
add_filter( 'year_link', 'wpd_endpoint_links' );
Related Posts:
- Put a link to a category round a hard coded A HREF
- How to query for pages/post depending on slug?
- php script to change slug in post automatically
- Custom route and query
- Custom post type permalinks do not appear using the link functions
- Remove slugs from custom posts type
- Allow two posts (from different categories) to have the same slug
- Test the existence of a page/article by its URL, taking in consideration the URL rewriting by filters
- Custom PHP form needs refresh to load page correctly
- Rewrite rule not working, but only when parameter is text
- Weird slug in archives permalink
- Query multiple custom post types in single loop
- Using Cookie Data For WP_Query Loop
- Alter secondary loop to exclude posts from current page category
- add_rewrite_rule with bottom priority doesn’t handle the WordPress pages
- Display Post co-authored in Author Page
- How is WordPress manipulating the posts like there are folders?
- Sorting Posts | Alphabetical Order
- Looking for most performant way to execute several similar WP queries within shortcodes
- Rename “Portfolio” slug?
- Global variable $post returning incorrect object
- How to securely provide a $_POST var in WP_Query with PHP 7?
- Create WP_Query to search for posts by their categories or their parent/child categories
- wp_query with cat not working
- If Query In Sidebar
- Recent Posts slider, using WP_Query(), loads duplicate sliders
- Compare post-IDs within WP_Query? (Less than / Greater than)
- How to use $query->set with post__in?
- Why do WP_Query results change after updating unrelated Advanced Custom Fields (ACF)?
- Display a specific category of products in shop page and disable code for specific actions
- WordPress returning 404 for multisite pages
- get_posts() and WP_query limits ‘AND’ conditions to a maximum of 6 for meta value queries in WordPress
- Custom query, checking values of multiple meta keys
- Redirect to another page using contact form 7? [closed]
- Fatal error: Call to a member function query() on a non-object
- Is it possible to retrieve all posts with a certain value for metadata?
- How to get all author posts outside of author templates
- How to get post permalink url without a href
- How to get post ID in a Page?
- stripping tags from excerpt in WordPress is not working
- Trouble inputting variable into WP query
- How to override url params with rewrite rules vars?
- page-slug.php not working but only for specific slug
- WP_Query | IF within $args array | Help me only add specific arguments if the argument is not blank
- How to display SQL query that ran in WC_Order_Query?
- Array to string conversion on array_map
- Store metakey value as an array
- Target post_date_gmt if it’s empty or not set
- Get all posts as an array ID => Name
- Post not populating for custom post type based on category selection
- Passing an array into WP_Query as a variable
- Custom query vars filters problem with pagination
- WordPress meta_query >= &
- Do not duplicate posts with multiple categories in multiple loops
- Infinite Loop – WP_Query
- Dividing the loop to style post differently
- Search only working on front page (index) , not working on other pages
- Displaying Event within two given time frames
- Remove Post if Advanced Custom Field is checked to fix paging
- WordPress permalink issue
- Search AJAX Filters – Multiple Query Loops Into One Loop (Optimization)
- WP_Query: How to get results from both meta_key options?
- Output product category link from WP_Query
- Passing in MySQL prepare statement parameter separately throwing error
- wp_Query with mutuplea values returns all posts
- Load more posts using AJAX based on posts inside WP_Query
- Custom search query on WordPress page not working
- How to select post ID for given parent name with nested prepared queries?
- posts_per_page displays only 2 posts instead of 4 posts
- Assign meta_query value to php variable
- Need to show 7 posts from actual date
- Add code to the header of posts by particular author
- Paged WP_Query is quitting on page 3
- Get Child of Child Pages in custom Menu
- Meta query not showing result properly
- Custom content using in_category
- Help on Wp_query to print an term
- What is the proper way to call a function (from functions.php) on a link click?
- Making list of posts with chosen description
- Ordering / grouping posts by datepicker ACF
- making a search.php query
- How do I generate formatted permalinks as specified in backend options?
- Efficient way of querying for a “fallback” post?
- How to add thumbnails from recent posts to owl-carousel in wordpress automatically?
- How to solve 404 permalink errors on nginx server
- Create a hierarchical loop at predefined markup requirements
- add_rewrite_rule questions
- Querying posts based off a jquery datepicker
- set new link as permalink
- Query seems to be duplicated
- append links with unique number string
- WP Query conflict on tag.php and category.php template
- custom data in url
- Keeping the previous get value and add another value when submitted
- Pagination in category.php not functioning
- Display all categories (with link) of custom post type – WordPress
- Add any username as link prefix and show data from that specific user’s profile on wordpress pages – with no login required
- how to goto specific page number including title with permalink
- WordPress 6.1.1 UTF8 Slug Limit Increase
- How do I exclude the current post from the upcoming post query