Plugin WordPress – Hidden Frontpage

The “RRAlves Hidden Frontpage” plugin provides a simple solution for WordPress users who wish to control the visibility of their posts on the site’s home page. Through an intuitive interface within the post editing area, this plugin enables authors to easily mark which posts should be hidden from the home page, adding an extra layer of flexibility to content management.

Its code is very simple and is available for download on my GitHub: rralves-hidden-frontpage. Feel free to download, use and change to your liking.

Features and Operation

  • Custom Meta Box: When an author or editor is working on a post, a new field appears on the side of the editing screen. This area, known as a meta box, contains a checkbox labeled “Hide from homepage.” This option directly determines the visibility of the post on the home page.
  • Saving the Checkbox State: Each time a post is saved, the current state of the checkbox is stored as post metadata. This means the visibility preference (to hide or show on the home page) is preserved and can be changed at any time by editing the post and adjusting the checkbox as desired.
  • Modifying the Main Query: The default behavior of the WordPress home page is to display the most recent posts. However, the plugin intercepts this query (only when viewing the home page) and modifies the search conditions to exclude posts marked to be hidden. It does this by adding a condition to the query that excludes posts with the metadata _rralves_hide_from_frontpage set to ‘1’. Posts without this metadata or with any other value are included, ensuring that only explicitly marked posts are hidden.

Advantages

  • Flexibility: Authors can control the visibility of each post on the home page, allowing specific content, such as announcements or notes, to be removed from the default view without affecting their publication on the site.
  • Ease of Use: The simple interface, based on a single checkbox, makes the process of hiding posts from the home page accessible even to less experienced users.
  • No Theme Changes Required: Unlike other approaches that might require modifications to the theme code, this plugin offers a solution that works regardless of the active theme, without the need for code changes or the creation of child themes.

Considerations

This plugin is particularly useful for sites that use the home page to display the most recent posts but occasionally need control over which posts appear. For instance, it might be desirable to keep promotional posts or specific event posts off the home page after a certain period. With the “RRAlves Hidden Frontpage,” managing this visibility becomes a simple task, offering site administrators and authors a powerful tool for optimizing content presentation.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.