Skip to content

Add filter for allowed nav item post status#30

Merged
sbrody merged 3 commits into
mainfrom
feature/filter-post-status
May 13, 2026
Merged

Add filter for allowed nav item post status#30
sbrody merged 3 commits into
mainfrom
feature/filter-post-status

Conversation

@sbrody
Copy link
Copy Markdown
Contributor

@sbrody sbrody commented May 13, 2026

Description of changes

This PR replaces the hard-coded addition of 'draft' to the status of posts allowed to appear in the long read nav, with a filter.
So, in a child theme or plugin the draft status can be added.

To test: Create a new style long read post. Add a draft article as a child of that post. It should not appear in the navigation.
Now, add this code to functions.php

add_filter('long_read_plugin_post_status', function($postStatus) { array_push($postStatus, 'draft'); return $postStatus; });

The draft article should now appear in the navigation, even for logged out users.

This is the second item of this card: https://trello.com/c/vjzEsXkS/337-enable-public-previews-for-content-including-long-reads

Checklist

  • Changelog updated
  • If new release: major version tag to be bumped after release (see docs)

@eirichmond
Copy link
Copy Markdown

@sbrody is there already a function.php that exists in the theme?

Copy link
Copy Markdown
Contributor

@RobjS RobjS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works well for me 👍

I guess one thing we might need to consider is that the sidenav on the parent page gets triggered by the existence of children even if those children are only in draft and the filter is not applied, so they aren't appearing in the sidenav. Meaning you end up with a sidenav that just lists the parent page. But that was pre-existing issue, so not one for dealing with here.

@eirichmond
Copy link
Copy Markdown

@sbrody is there already a function.php that exists in the theme?

apologies, read that test as literal, should have realised its wrapped up in a framework ><

@sbrody
Copy link
Copy Markdown
Contributor Author

sbrody commented May 13, 2026

@sbrody is there already a function.php that exists in the theme?

apologies, read that test as literal, should have realised its wrapped up in a framework ><

We tend to move functions.php into templates/

@sbrody sbrody merged commit ee42008 into main May 13, 2026
2 checks passed
@sbrody sbrody deleted the feature/filter-post-status branch May 13, 2026 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants