You have not specified exactly when your code runs but you can hook into “request” to check the requested page:
add_filter( 'request', function( $request ){
if( isset( $request['feed'] ) ){
//This is a feed request
}
return $request;
});
When the requested page is a feed $request
, which is an array of query variables, will contain an item called “feed” which is set with the name of the feed like “rss” for example.
https://codex.wordpress.org/Plugin_API/Filter_Reference/request
Related Posts:
- How to check if the current page is at a specified path in the URL?
- Getting only direct child pages in WordPress with get_pages
- Disable Attachment Pages Completely
- Multiple is_page() in page.php
- Create WordPress pages with PHP
- Is it possible to generate a page without create in the admin?
- WordPress admin never finishes saving page on site with large page count
- class=”parent” for wp_list_pages?
- PHP Script within wordpress theme
- Listing all sub-pages?
- fetch_feed: retrieve entries in the appearing order, not chronologically
- Concatenate site_url and string doesn’t work
- What’s the proper way to use wp_enqueue_script/style?
- Help with a custom page template – listing contents of childpages?
- Callback URL in WordPress
- Print number of post (in reverse)
- Wrong links in WordPress?
- How is WordPress manipulating the posts like there are folders?
- Why does running get_the_excerpt() when generating JSON file take 28 seconds vs. 599 milliseconds without it?
- How can the plugin directory path be returned into ?
- Add a Different CSS Class Into The Body Tag of Different WP Pages
- Limit get_pages to only show 5 items
- syntax issue on php 7.4
- How do I publish only one page to production after making changes on staging?
- Extract subdomain and relative address from a url
- Custom Template 404 for specific custom post type
- Can’t load WP function into external function
- Custom category code not showing all posts
- Why does WordPress remove my variables in the URL?
- Insert a button on a page with random number generation
- Global variable $post returning incorrect object
- Page Automatically Generated from Theme?
- Sort query_posts for Parent Pages to menue order or the count?
- Dynamic content based on a URL parameter
- My page.php shows the index.php
- Scrape external webpage for first image and add it to new post
- Search Query: how to construct a search string from two select elements?
- Need help enqueueing webfonts
- Use .php file as page instead of wordpress page & template file?
- Why is $wp->request empty in WordPress 6.0?
- How to pass a PHP $_GET variable and fetch/output it?
- How to modify the default feed via a function
- trouble with page_id & highlighting current page
- Apply class to every third list item? [duplicate]
- How to include custom code on a page that’s set to act as homepage?
- What’s the best way to include PHP code in pages?
- Automatically add images to a menu
- page-slug.php not working but only for specific slug
- Need php code’s output to display underneath a Divi Module
- How to add page numbering with php?
- Display child page content of a specific parent on home page
- Can’t change website Title on wordpress
- How to use title attributes in sidebar widget?
- Unique PHP on each Page
- How to Display a List of Child Pages For a Parent Page in WordPress
- If is page, archive or search output this code
- WordPress Search
- How do I include an external PHP file in a subdir WordPress install?
- How to add PHP pagination to wordpress
- Toolbar Hidden in a Virtual Page
- Aspx/Rss feed – failed to open stream: Redirection limit reached
- Page load timer?
- WordPress permalink issue
- How to define a rule in functions.php that ONLY disables the default wp functionality that undesirably changes ‘&’ to ‘#038;’?
- Edit and delete permissions pages and posts
- A function to get the content of a page
- Allow two posts (from different categories) to have the same slug
- Prepend to all image URLs with PHP, only for mobile devices
- How can I check if a post with a particular slug or title exists?
- When I click for the redirect link it is showing the content of index.php instead of single_assignment_page.php
- Category Page Displaying all Pages
- Rewrite rule not working, but only when parameter is text
- WordPress/NGINX not respecting the category URL for new posts
- Child and Parent Pages list of sub pages
- Static Page with php echo [duplicate]
- How to tell if a page has subpages for Custom Post Types
- WordPress add_rewrite_rule
- Use page-templates without creating theme
- How do I generate formatted permalinks as specified in backend options?
- Newbie question. Login/Registration. New PHP page
- Previewing/Updating some Pages causes “The requested URL was rejected” Error
- Adding my own custom template page but got white page
- extract url from a hyperlinked string in PHP [closed]
- Execute php in pages
- Why isn’t my link attribute getting my css?
- How to map my php files as the files for pages
- Removing all my hardcoded URLs with get_site_url()
- Retrieve first image url from custom post with pagination
- Show results for multiple page-types
- How to add feature image url in my template file and content as well?
- Display selected parts from selected pages on the frontpage?
- Adding Media button to only pages
- Get current WordPress page then add #post ID to the end
- How to include support for all page types, calendar urls, archive, etc
- How to refresh a template page on WordPress in 3 seconds – easiest method?
- How to handle parent and child pages?
- How do I remove blog entries from home page Twenty Eleven child theme?
- append special url end of my website urls
- hello can you advise how to fix the error?
- Create a custom plugin with dynamic child pages listing database records