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
- Capture the Selected Radio Button Value between two files in wordpress theme
- Why have on every line
- Cleaning up WordPress to improve performance?
- Proper use of Output Buffer
- Include a external PHP file into a WordPress Custom Template
- Need help setting default setting value for radio button in theme customizer
- Get author full name
- How to remove hardcoded characters from playlists?
- function_exists call in function.php
- Fatal error: Call to undefined function plugin_dir_path()
- How to preserve PHP modifications while upgrading WordPress?
- Is it possible to get a theme customizer setting from wp.customize using jquery?
- Debugging an error: wp_enqueue_style was called incorrectly
- How to get the registered sidebar’s name by its id?
- is there a simple way to list every templates / php files used to generate a specific page?
- 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
- Hide a menu-item and its submenus and display a ‘Log in’ link if the user is logged out
- The best way to customize “nav-menu-template.php” to add if the ‘link_before’ is “checkbox”
- 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
- Authenticating to WordPress, using my own authentication two-factor system
- delete an array element when its date expires
- Understanding WordPress child theme custom JS loading
- Why is PHP Cookie via plugin only set when logged in as Admin and not regular users? and other questions
- 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?
- Disable External Pingacks on WordPress Posts and Only Allow ‘Self Pings’
- Remove css styles from specific page
- Is the regular ajax request method safe or I should use admin-ajax.php?
- Custom plugin issue when trying to use the shortcode twice on a page [closed]
- do not show web page section when using advanced custom fields pro
- Overriding a theme redux file in child theme
- Widgets not showing in my custom theme
- Using wp_get_image_editor in a standalone script
- How do I list the_tags() into HTML data-attribute
- New Plugin Review
- Am I not understanding plugins?
- Using Font Awesome as post thumbnail
- Can I change a variable in a content part while calling it?
- 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
- Making Quote Plugin more efficient
- How to access function from outside of a class within this class in WP plugin?
- What is the fastest way to load PHP functions that are only used in one theme template?
- My Own layout in WooCommerce pages [closed]
- Differences when using the the_time and the_date functions
- custom shortcode will not display the wrapped content
- Can’t load WP function into external function
- Displaying theme options in css
- Set WordPress Default Template
- Setting custom canonical urls
- Trigger popup in a php if/else statement
- Customizer: Output default value in Customizer CSS
- Adding Default Settings to Theme My Login plugin
- How can i upload images in an admin page?
- Swapping wp_dropdown_categories function with wp_category_checklist
- How to customize a permalink (URL) structure?
- How to access global variable $menu inside a class function
- How to remove the cufon script from Dzonia Lite theme [closed]
- 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?
- How to set up VS Code for WP plugin/theme development in 2021? [closed]
- How to check if a meta value has already been assigned to any user?
- filter default query to show just selected level of child pages in wordpress
- How to pick the default selected value in wordpress dropdown?
- Improve page speed loading using CDN and async or defer attribute
- How to call plugin function per site in a multisite?
- Error in custom php function doesn’t exist
- Customizer: active_callback and sanitize_callback incompatibility?
- Populate editor with some content of a page with a page template
- Catchable fatal error: Object of class stdClass could not be converted to string after WP 4.7
- Menu jumping when calling it via PHP