Skip to content
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

Exclude the current post from yet another area where we're creating lists of IDs #1403

Merged
merged 2 commits into from
Feb 22, 2017

Conversation

benlk
Copy link
Collaborator

@benlk benlk commented Feb 22, 2017

Changes

  • exclude the current post's ID from the list of ids generated by add_from_query, the method of the class that is responsible for generating lists of IDs in multiple parts of the Largo_Related class.

Why

Something in one of the two calls to WP_Query in Largo_Related->get_series_posts() is ignoring the post__not_in argument on the query, so now I'm going to just exclude the current post's post ID from ever being added to the list of IDs

This is because of HelpScout ticket 559, and is a continuation of issue #1381 and the work done in PR #1385.

Copy link

@rclations rclations left a comment

Choose a reason for hiding this comment

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

just some minor code standards stuff, otherwise g2g

! in_array( $q->post->ID, $this->post_ids ) // only add it if it wasn't already there
&& $q->post->ID != $this->post_id // do not add the id of the current post, because we do not want to ever return that
) {
$this->post_ids[] = (int) trim($q->post->ID);

Choose a reason for hiding this comment

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

spaces inside trim() parenthesis

$this->post_ids[] = (int) trim( $q->post->ID );
if (
! in_array( $q->post->ID, $this->post_ids ) // only add it if it wasn't already there
&& $q->post->ID != $this->post_id // do not add the id of the current post, because we do not want to ever return that

Choose a reason for hiding this comment

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

!==

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think we should allow type juggling here, because of the possibility that we may be comparing a string post ID to a numeric post ID.

Choose a reason for hiding this comment

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

makes sense

@benlk benlk merged commit 5f0ba34 into master Feb 22, 2017
@benlk benlk deleted the 1381-take-2-more-excluding-current-post branch February 7, 2018 22:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants