Skip to content

Latest commit

 

History

199 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Post Type Spotlight

Post Type Spotlight

Feature any post type — posts, pages, attachments, or your own — and then query, style and sort by that flag.

Latest Release: 3.1.1

Status Quality
Release PHP
Plugin Check JavaScript
Playground Tests

See CHANGELOG.md for release history and detailed changes. Full documentation is in docs/post-type-spotlight. It publishes to docs.linchpin.com once sync-docs.yml is promoted out of its dry-run posture.

Description

The plugin adds a Feature this post control to the editor. It only appears on the post types an administrator enables under Settings → Writing.

When a post is designated as featured:

  • It receives featured and featured-{$post_type} classes through the post_class filter.
  • A ⭐️ appears in a Featured column on that post type's admin list screen, with a Featured view that filters to just those posts.
  • It is assigned the hidden pts_feature_tax taxonomy term featured, so it can be queried with a standard tax_query.

Because the flag is a taxonomy term rather than post meta, finding featured content is an indexed taxonomy lookup instead of a meta query. WordPress' own sticky posts only work on the core post type; this works on any type you enable.

Requirements

Requirement Version
WordPress 6.1 or later
PHP 7.4 or later

Installation

  1. Upload the plugin folder to /wp-content/plugins/, or install Post Type Spotlight from the Plugins screen.
  2. Activate it through the Plugins menu.
  3. Go to Settings → Writing and tick the post types that should gain the featured control.

Step 3 is the one that makes the plugin do anything, so until it is done an admin notice links straight to that screen, and the plugin's row on the Plugins screen carries a Settings link to it.

Usage

Featuring a post

In the block editor, the Summary panel of the sidebar gains a Feature Post type toggle. In the classic editor, the Publish meta box gains a checkbox whose label is filterable through pts_featured_checkbox_text.

Querying featured posts

$featured = new WP_Query(
	array(
		'post_type'      => 'post',
		'posts_per_page' => 10,
		'tax_query'      => array(
			array(
				'taxonomy' => 'pts_feature_tax',
				'field'    => 'slug',
				'terms'    => array( 'featured' ),
			),
		),
	)
);

Swap 'operator' => 'NOT IN' into that clause to exclude featured posts instead. For a single post, has_term( 'featured', 'pts_feature_tax', $post_id ).

The Featured List block

A Featured List variation of the core Query Loop block ships with the plugin. Search the inserter for featured or spotlight to find it.

Its Spotlight panel sets which posts the loop returns — Only featured, Featured first (everything, featured posts sorted to the top), or Exclude featured. How many it returns is the Query Loop's own Items per page setting.

Full walkthrough: The Featured List block.

Getting set up locally

Prerequisites:

  1. Node.js >=20.20.2 (see .nvmrc)
  2. PHP 8.2 for the toolchain — note the plugin itself still supports 7.4
  3. Composer
composer install
npm install
npm run build

npm run build compiles blocks/src into blocks/build, which is committed because the plugin loads it at runtime. Use npm run start to watch.

Quality checks

composer lint            # parse lint + PHPCS against the Linchpin standard
composer phpcbf          # auto-fix what PHPCS can
npm run lint:js
npm run lint:css
npm run test:playground  # boots the plugin in WordPress Playground

A pre-commit hook runs composer check-staged-cs, which scopes PHPCS to the lines a commit actually changes rather than whole files.

Tests and screenshots

The test suite boots the plugin in WordPress Playground and drives its real admin screens with Playwright. Each spec captures a screenshot; in CI those upload as artifacts and post back to the pull request, so a visual regression in the editor sidebar or the posts list shows up in review.

npm run test:playground:headed  # watch it run
npm run test:playground:ui      # Playwright UI mode

Specs live in tests/playground/specs. blueprint.json seeds the Playground instance. A second blueprint at .wordpress-org/blueprints/blueprint.json powers the Live Preview button on WordPress.org and installs the released plugin from the directory instead.

Build process and releases

Versioning is handled by release-please. Commit with Conventional Commits and it opens a release PR that bumps the version across post-type-spotlight.php, readme.txt, package.json and this file, and writes the changelog. Merging that PR tags the release, which triggers the GitHub release zip and the WordPress.org SVN deploy.

bash scripts/build.sh produces the distributable at build/post-type-spotlight — the same artifact Plugin Check inspects and the release ships.

Never hand-edit CHANGELOG.md, .release-please-manifest.json, or a version string in a file release-please owns.

Coding standards

PHP follows linchpin/coding-standards via phpcs.xml.dist. testVersion is pinned to 7.4- rather than the standard's default, because the toolchain runs on PHP 8.2 while the plugin still ships to hosts on 7.4.

Linchpin

About

Allows admin chosen post types to have a featured post check box on the edit screen. Also adds appropriate classes to front end post display, and allows featured posts to be queried via a taxonomy query.

Topics

Resources

Stars

1 star

Watchers

3 watching

Forks

Releases

Used by

Contributors

Languages