The last line tells WP to run this function on the pre_get_posts
hook. That hook is the ideal place to modify the main query that will be run in order to build the page. In this case, exclude_featured_tag()
checks whether WP is loading the home page, and whether it’s about to call the main query for the page (as opposed to any other secondary queries being run). Then it modifies the query ($query->set()
) to NOT include any post that has tag of ID OF THE FEATURED TAG
.
For more on the pre_get_posts
hook, see the codex.
Related Posts:
- How to obtain the current website URL in my theme?
- Function to return true if current page has child pages
- List of all theme customizer control types?
- Set the transport of the Customizer ‘header_image’ core setting to ‘postMessage’
- Why WordPress architecture is not pure object oriented and it don’t use MVC pattern? [closed]
- PHP can I add line numbers to file_get_contents()
- Create another “Display Site Title and Tagline” checkbox, “Header Text Color” setting and control
- Converting HTML Template to WordPress Theme
- what is the best practice to add new field to an api route
- Retrieve $_POST data submitted from external URL in WordPress(NOT API)
- Compare the old get_theme_mod($name) to the new get_theme_mod($name) return value
- Redirect to another page using contact form 7? [closed]
- Is there a hack for using is_page() within the function.php file?
- How to change basename url for wp-admin?
- Where can I find the declaration of `$_wp_theme_features`?
- A Customizer checkbox control that sets the setting to “” or to “blank” and show() or hide() a color control
- My customizer’s setting doesn’t set to the default and needed to click the control’s “Default” button before it’ll be set
- WordPress causing all code to be displayed on line 1. Receiving multiple errors after cleaning cookies and cache
- How to add button to top of theme customizer?
- WP Custom tables query
- Need help setting default setting value for radio button in theme customizer
- Get author full name
- Is it possible to get a theme customizer setting from wp.customize using jquery?
- Dynamic URL to reference custom PHP files
- Dynamically change feature image in customiser
- One button to change all settings in theme customizer?
- Change comments form title on a page by page basis
- How to use copy() function and paste file in /wp-content/themes directory
- Setting up the child theme so as to enable right-to-left WordPress?
- Design view breaking on Pages
- How can I loop into two different DIVS without repeating the DIVs
- Removing unnecessary wordpress files
- How to add default images into theme customizer image control?
- Am I not understanding plugins?
- How to make thumbnail image fit into a div where image dimentions are completely different?
- How to break down importing of feeds
- Custom Logo URL | Help me print the URL of the custom logo I inserted into my theme
- How to access function from outside of a class within this class in WP plugin?
- Displaying theme options in css
- Adding Default Settings to Theme My Login plugin
- Swapping wp_dropdown_categories function with wp_category_checklist
- How to customize a permalink (URL) structure?
- Edit Yoast SEO breadcrumbs output [closed]
- Hide categories that are not used in the post type
- How can I remove a function that has been added to wordpress with add_filter?
- How do I add custom bulk actions to multiple custom post types?
- filter default query to show just selected level of child pages in wordpress
- Error in custom php function doesn’t exist
- Customizer: active_callback and sanitize_callback incompatibility?
- Menu jumping when calling it via PHP
- Modify custom field input data before creating a new post
- How to disable controls in theme customizer?
- Is there a way to conditionally check whether a WordPress post title is empty?
- Use WordPress function in php file
- Underscore – Self hosted fonts
- Using data sent via AJAX in multiple functions on a WP plugin
- Theme not calling Jquery properly
- Function Reference Documenting Template Tags for use in Custom Theme Templates?
- How to add the sidebar to all the pages except the home page? [closed]
- how to save checkbox data for custom setting?
- Create page template via functions.php?
- How to create a field in customize and show that in header.php?
- How to make function appear in sentence?
- Removing “Powered by” footer using child theme PHP [closed]
- How to add aria role and schema markup to custom walker container
- Removed jQuery script from header.php , any problems?
- Execute Jquery when a specific page in my plugin is loading
- pass html code to worpdress
- Customize field names in backend profile edit page through function.php [duplicate]
- Getting text from custom field from customizer
- Need help for some PHP code
- how to replace h1 entry title with h2 in category pages only
- Only the first image uploads
- Illegal string offset checkbox
- Problem with displaying CSS Stylesheets – Am I adding them correctly in my wordpress child theme?
- require get_template_directory() . ‘path/to-my/file.php’ BREAKS customize > themes functionality
- Custom Plugin: How to Include Install Buttons of other 3rd Party Plugins?
- Custom plugin: how do I call a PHP file if settings option is set to true?
- Rename a folder via HTML POST request
- working code, not working – Plugin Dev
- Submit remote form to wordpress REST API and save data to custom post type
- How to identify which php file a plugin is using on page load?
- In a foreach loop, how can I add a meta value if it doesn’t exist?
- Store user form submitted information in post type
- Add a custom link to each image in WordPress gallery
- post_exists stops working in a scheduled event
- register dependency css and js inside a plugin class
- Taxonomy Child Term, Counter is staying on 0
- Remove node from multisites?
- PHP get_category() function redeclared
- How to get php file based on URL in WordPress
- How can I customize a WordPress theme before it’s downloaded?
- Private messaging – Getting and displaying the avatar/url of a message recipient
- Extend the WP_Customize_Image_Control class to change its non-frame $button_labels
- Can anyone tell me why I can’t edit a plugin when it is installed without having to re-install?
- Adding code to the function file
- Issues separating my Plugin pages into different files
- How do I change the Go To Categories link in the term_updated_messages
- Variable ++ in query loop
- Woocommerce Convert existing order to the cart