Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add methods to hide filled and expired posts #2449
base: trunk
Are you sure you want to change the base?
Add methods to hide filled and expired posts #2449
Changes from 1 commit
5afad7d
7a924f6
41f374d
2fccb36
eeb42e0
068a162
d1d04d4
cd94313
3fedb2b
fc8e201
2522485
27685ac
d3b5123
d23b3a3
ea63e66
3a210fb
1a7b7da
de746c4
82e75e6
27b3be7
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jom Here's the refactored implementation for setting
'public
on the post status registration. The logic is slightly different than discussed but noted in the comment. In testing:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable name threw me off a bit, but I think the ultimate logic is correct!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ended up reverting this due to issues checking conditionals like
is_archive()
. Committed 1a7b7daThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main issue we were avoiding with the other strategy was
$query->set( 'post_status', 'publish' )
removing other custom public statuses from the search. I actually wonder if this was fixed in core (5.9) with https://core.trac.wordpress.org/changeset/49830. It should now be respecting ourexclude_from_search
when registering theexpired
post status. Did you find in testing that expired posts were showing up in search results still?I wonder if we should be setting
exclude_from_search
based on our setting. Since that fix in core, I'm guessing we're hiding expired results from search even when we shouldn't be.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, gotcha.
exclude_from_search
is already set totrue
:WP-Job-Manager/includes/class-wp-job-manager-post-types.php
Lines 395 to 407 in 0568f04
This does not exclude expired jobs from WP Search.
This seems to be getting overwritten by the
exclude_from_search
parameter on the post-type registration:WP-Job-Manager/includes/class-wp-job-manager-post-types.php
Line 369 in 0568f04
If this is set to
true
, then posts with anexpired
post status are, as expected, excluded from search -- but so is anyjob
type post.When I was testing the
'public' =>
manipulation, it worked for$GET_['s']
but did not work for archive pages as helper methods were always returningfalse
. Maybe there's a way around that, that I haven't thought of?I'm wondering if another option would be to keep the
$query->set()
, but instead of setting it topublish
, retrieve all post statuses withget_post_stati()
, remove what we don't want, and then pass everything else. Though, that seems a bit... hacky?IIUC, this is more to do with the issue report here https://core.trac.wordpress.org/ticket/44737, which is sitting stale. Making the suggested fix does fix the behaviour, but then that's a whole core-related thing.
cc @yscik
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I saw https://core.trac.wordpress.org/ticket/44737, but then saw the lines get changed in https://core.trac.wordpress.org/ticket/48556 and thought that would fix it, but now I can see what it is doing in the
} elseif ( ! $this->is_singular ) {
block.This is what I was going to suggest before I went down the 44737 rabbit hole because it seems like WP is doing this in a way that would work for us:
https://github.com/WordPress/WordPress/blob/32e94b4de108fb090ebc678b48113b8954f7f188/wp-includes/class-wp-query.php#L2587-L2593
I think if we did this we could just removed
expired
(I'm guessing)? It is a bit hack-y, but might be okay.The only other thought I had is modifying the global that holds the post status objects here after our conditionals and then restore
public => true
in theposts_selection
action, but that might feel more hacky.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jom Here's the latest approach, which we talked about
82e75e6