Skip to content

Featured Content: Posts are returned when no tag is chosen. #6607

@anastis

Description

@anastis

It seems there is bug where seemingly random featured posts are returned when there is no tag chosen from the Customizer.

Steps to reproduce the issue

In a clean WordPress installation, install/activate Jetpack and a theme that provides support for Featured Content, such as Automattic's Shoreditch
Import the Theme Unit Test file, or create some content.
Make sure a tag "featured" doesn't exist at all.
Make sure some other tags exists and have posts assigned.
Go to Customizer -> Featured Content and make sure "Tag name" is empty.
Save and exit the customizer.

What I expected

No featured posts should appear.

What happened instead

Featured posts appear.

Digging in, Jetpack calls get_term_by( 'name', $settings['tag-name'], 'post_tag' ); in https://github.com/Automattic/jetpack/blob/master/modules/theme-tools/featured-content.php#L215
When $settings['tag-name'] is empty however, WordPress returns a seemingly random term object instead of a falsey value (in my tests it looks like it returns the tag with the lowest term_id).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions