Skip to content

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

@benlk

Description

@benlk

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions