In your second code you use undefined $post
variable. Probably you meant a global $post
, but as the second parameter to the filter is passed the ID of the post for which the link is created, and this does not necessarily have to be the current post of the loop.
Try this:
add_filter( 'page_link', 'nocfcache_query_string', 10, 2 );
function nocfcache_query_string( $url, $id )
{
$ids = array (399, 523, 400, 634, 636, 638);
if( in_array($id, $ids) )
{
$url = add_query_arg( 'nocfcache', 1, $url );
}
return $url;
}
Related Posts:
- remove “index.php” from permalinks
- How does WordPress create URLs that Apache knows about?
- Stop WordPress appending `-2` to the end of my url after i change it
- Get default permalink structure from pretty URL’s
- Get current URL (permalink) without /page/{pagenum}/
- How to get pretty URLs with add_query_arg in permalinks
- Creating custom permalink structure for languages
- Getting the Site URL Including the Front Base
- How to use relative links on my pages?
- WordPress Permalink changes to question mark (?) in URL
- Adding another word in front of post url
- Removing hierarchical pages in the permalink
- why does anchor name add a slash to url?
- URL Rewrite + Page + Custom Post Type = Unusual Redirect
- WordPress on a subdirectory of Laravel – WordPress pretty permalinks inner page shows laravel
- How to create a permalink structure for posts in a specific category
- How to get url of a post from admin panel
- How to Remove Slug From Database?
- How to make draft posts or posts in review accessible via full url / slug?
- Remove subfolders from URL
- flexible rewrite ‘ramble’ URLs with WordPress
- How to get the post id from a permalink?
- Custom rewrite rules for feeds of custom queries (query_var query strings in URL)?
- Make attachment pages require a base url
- How to Remove -14 from WordPress URL (Permalink)
- How to Modify Existing Rewrite Rules?
- display URL or permalink instead of page title in dashboard
- Change permalink rule if category is called “uncategorized”
- Can two products with the same name but different category produce unique URLs?
- Get canonical link
- Get closest page ID from URL
- How to reset canonical URLs / fix redirect loop
- CSS not loaded when omitting www. part of URL
- Setting up two separate blogs while using WordPress as a CMS
- How to show the homepage on a different url, like site.com/blog instead of site.com?
- wordpress api using rest_route for other pages
- Get page by path – honoring permalink settings (urls w/slashes)
- Change blog segment of URL
- How to stop WordPress from removing & from URL?
- Non latin post slug truncate
- How to bulk edit image url in featured image and product description?
- Is there a link parameter that will show me all my published pages?
- How can i have a custom post type with more slugs for each post?
- URL rewriting: removing the site’s basename for a specific category
- Get the url of a page template without using the page slug and ID
- Remove -2 from URL; no duplicate pages, no images, no pages in trash
- WordPress keeps giving me the wrong permalink
- display dynamic content based on url slug on custom page
- How to generate a list of all urls
- Relative v.s. absolute URLs: which ones should I use for cross-domain portability?
- How to use all tags in post permalinks
- Unique one time use URL
- Edit permalink for certain pages
- cannot link a external url, present page url acting as parent url
- Remove parent page from url
- Getting back a permalink from custom url
- Two URLs of one post is available
- Bulk append URL (add word to slug)
- Access posts while mod_rewrite is broken
- Remove international characters from slug – Almost done – Bit help
- replicate url permalink after migrating to wordpress
- Can I change the URL structure for a CPT only?
- How to remove slug from front page?
- How to redirect old permalinks from https://exmaple.com/category/post_id to https://exmaple.com/category/post_id.html
- Make a post inaccessible without a unique ID in the URL
- Multiple Taxonomy Items for Separate URLs
- WordPress keeps removing query var from the URL
- URL gives 404 error of my subfolder site when i change permalink
- How to construct a dynamic rewrite rule for child pages that passes more than one query var
- Why does one of my pages not have the option to edit the link?
- Using a template file for a specific custom URL
- Nested permalink without dummy parent page
- Giving specific category posts its own permalink structure returns 404
- Extra url paths as variable
- Passing parameter through permalink structure
- Custom Taxonomy rewrite rule causes 404 error on page or single post depending on if it’s set to “True” or “False”
- Post links broken after migration
- Added a prefix in URL permalink structure but the old structure still working!
- rebuilding/ rewriting a url to make it SEO friendly
- How to change the URL using rewrite rule in wordpress
- Get value from URL with different types of parameters
- a way to support totally different url structure
- add bar in paging in the URL
- WordPress Page URL
- Remove/hide a specify category-name from the url
- How to change URL of my pages?
- Difference and usage of uri (e.g. get_directory_uri) and absolute path (e.g. get_directory)
- Imported posts using wrong domain name
- How to display post permalinks instead of pages?
- Using a taxonomy value as part of a post URL
- Why is there a # and other characters in URL for WordPress site?
- How to avoid duplicate Url for the home page
- Are custom page templates being used to get this permalink structure
- Change permalink in wp-property
- Include language variable in url
- Removing parent page in URL for one page
- How to get the perfect WordPress, WooCommerce, Custom Post Type pretty permalinks?
- WordPress keep redirecting me to random URLs
- Standard Htaccess directives disappear by themselves
- Change default URL (or permalinks) in the back-end