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

largo_category_and_tags does not accept specification of an arbitrary post ID #1647

Open
benlk opened this issue Mar 15, 2019 · 2 comments
Open

Comments

@benlk
Copy link
Collaborator

benlk commented Mar 15, 2019

Consider the following code:

largo_top_term( array('post' => 5 ) );

Assuming that post 5 has a top term set, the top term returned will be that set on post 5.

If no top term is set on post 5, largo_top_term() calls largo_category_and_tags() to get a list of categories and tags. That function doesn't use post 5, but instead fetches terms from the get_the_ID() post, which in many situations (like the homepage) is not the post that we want terms for.

There are two situations to consider:

  1. On a largo_top_term() call with a specificied post that does not match the global post ID. In this situation, we should not call largo_category_and_tags(), because its output will be wrong.
  2. On a largo_top_term() call with no post specified, largo_top_term() will get the post ID to use from get_the_ID() the same as largo_category_and_tags(). This use case includes the top term on single posts.

Identified during work on #1646

@benlk benlk added type: bug priority: low Nice-to-have in a release. labels Mar 15, 2019
@benlk benlk added this to the 0.6.2 milestone Mar 15, 2019
@benlk
Copy link
Collaborator Author

benlk commented Mar 15, 2019

We can't remove largo_category_and_tags() from largo_top_term() as a fallback, yet, but we should not also go around outputting incorrect terms. Until largo_category_and_tags() is refactored to make it easier to specify the post ID, we can check in largo_top_term() for a mismatch between the specified post ID and the global post ID, and not call largo_category_and_tags() in that situation.

benlk added a commit that referenced this issue Mar 15, 2019
…tags(), and a fix for #1647 by not calling largo_category_and_tags() when the post given to largo_top_term() does not match the post returned by get_the_ID()
@benlk
Copy link
Collaborator Author

benlk commented Mar 15, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant