Skip to content
The Admin Bar
  • Get Involved
    • Facebook Group
    • Barfly Community
    • TABLE Mastermind
  • Learn
    • Articles
    • Events
    • Newsletter
    • YouTube
    • WordPress Professionals Survey
    • SEO Weekly
    • Security Weekly
    • Accessibility Weekly
  • Products
  • About
  • Free Stuff

Using Custom Taxonomies and CSS to Target Specific Items in a Query Loop

While building out a Black Friday deals page this week, I ran into a challenge: I needed to highlight specific items inside a Query Loop without affecting all the items. If you’ve worked with …

Kyle Van Deusen

Kyle Van Deusen

Published:

November 10, 2023

Filed Under:

General

Kyle Van Deusen

Kyle Van Deusen

The Admin Bar

After spending 15 years as a graphic designer and earning a business degree, I launched my agency, OGAL Web Design, in 2017. A year later, after finding the amazing community around WordPress, I co-found The Admin Bar, which has grown to become the #1 community for WordPress professionals. I'm a husband and proud father of three, and a resident of the Commonwealth of Virginia.

Feels like magic
This content contains affiliate links. View our affiliate disclaimer.

While building out a Black Friday deals page this week, I ran into a challenge: I needed to highlight specific items inside a Query Loop without affecting all the items. If you’ve worked with Query Loops before, you know that anything you add to the loop applies to every item displayed.

To solve this problem, I used a custom taxonomy combined with a bit of CSS. This solution is quick to implement, provides a lot of flexibility, and can be adapted for various use cases. In this post, I’ll walk you through the exact situation I faced and the steps I took to solve it.

YouTube video

The Problem

On my Black Friday deals page, I had three separate Query Loops:

  • Gold placements
  • Silver placements
  • Bronze placements

Each loop displayed a set of deals, and I wanted to highlight the products I created by adding a small verified badge in the top-right corner of those items.

The challenge was that Query Loops repeat the same structure for every item, so there’s no way to add an icon to just specific items without affecting all of them.

The Solution

To target specific items, I used a custom taxonomy to assign a unique class to those items. Then, I wrote CSS to style only the items with that class.

Step 1: Create a Custom Taxonomy

First, I created a custom taxonomy using Advanced Custom Fields (ACF). You can use the free version of ACF for this.

  1. Add a New Taxonomy:
    • In the WordPress admin, hover over ACF and click Taxonomies.
    • Click Add New and name the taxonomy (e.g., “Origin”).
    • Set the plural label to “Origins” and the singular label to “Origin.”
  2. Configure the Taxonomy:
    • Enable the checkbox option for easier selection.
    • Assign the taxonomy to the relevant post type (in my case, a custom post type called “Deals”).
  3. Save Changes:
    • Click Save Changes to create the taxonomy.

Step 2: Add Taxonomy Terms

Next, I added terms to the taxonomy.

  1. Go to the Taxonomy:
    • Under the “Deals” post type, click on the new “Origins” taxonomy.
  2. Add Terms:
    • Create a term called “Internal” to represent products I created.
    • Optionally, add other terms like “External” for products from other sources.

Step 3: Assign the Taxonomy to Posts

To apply the taxonomy to specific posts:

  1. Edit Posts:
    • Go to All Deals and edit the posts you want to highlight.
    • In the post editor, check the “Internal” box under the “Origins” taxonomy.
  2. Save Changes:
    • Update the posts to apply the taxonomy.

Step 4: Inspect the Front End

At this point, there won’t be any visible changes on the front end. However, if you inspect the page using your browser’s developer tools, you’ll see that the taxonomy has added a new class to the relevant items.

For example:

  • The post with the “Internal” taxonomy will have a class like origin-internal.
  • Posts without the taxonomy won’t have this class.

Step 5: Write CSS

Now that the taxonomy is adding a unique class to the items, we can use CSS to style them.

  1. Open the Customizer:
    • Go to Appearance > Customize and open the Additional CSS section.
  2. Target the Class:
    • Write CSS to target the origin-internal class.
    • Start by adding a temporary outline to confirm you’re targeting the correct items:

css

.origin-internal {
  outline: 1px solid red;
}

Once confirmed, you can style the items as needed.

Adding the Verified Badge

To add the verified badge, I used a pseudo-element and positioned it in the top-right corner of the item.

  1. Set Positioning:
    • Add position: relative to the parent container:

css

.origin-internal {
  position: relative;
}
  1. Create the Pseudo-Element:
    • Use the ::after pseudo-element to add the badge:

css

.origin-internal::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  background-image: url('URL_TO_YOUR_IMAGE');
  background-size: contain;
  top: 24px;
  right: 24px;
}

This positions the badge in the top-right corner of the item.

Step 6: Apply the Taxonomy to Other Posts

To highlight additional posts, simply assign the “Internal” taxonomy to them.

  1. Quick Edit:
    • Use the Quick Edit option in the post list to quickly apply the taxonomy to multiple posts.
  2. Save Changes:
    • Update the posts and refresh the front end.

Now, all posts with the “Internal” taxonomy will display the verified badge.

Step 7: Add Context

To clarify the meaning of the badge, I added a note at the bottom of the page:

“The verified icon indicates an official Admin Bar product.”

This helps users understand the significance of the badge.

Other Use Cases

This system isn’t limited to Black Friday deals pages. Here are a few other ways you could use it:

  • Featured Blog Posts: Highlight specific articles by tagging them with a custom taxonomy and styling them differently.
  • Promoted Products: Add badges or special styling to products you want to promote.
  • Custom Layouts: Use taxonomy-based classes to create unique layouts for certain posts.

The possibilities are endless, and the only limitation is your imagination.

Wrapping Up

Using a custom taxonomy and CSS to target specific items in a Query Loop is a powerful and flexible solution. It allows you to highlight or style individual items without affecting the rest of the loop.

If you try this method, I’d love to see how you use it in your projects. Feel free to share a link—I always enjoy seeing these techniques in action!

Happy designing!

Share This Article!
FacebookXLinkedInEmail
Kyle Van Deusen

Kyle Van Deusen

The Admin Bar

After spending 15 years as a graphic designer and earning a business degree, I launched my agency, OGAL Web Design, in 2017. A year later, after finding the amazing community around WordPress, I co-found The Admin Bar, which has grown to become the #1 community for WordPress professionals. I'm a husband and proud father of three, and a resident of the Commonwealth of Virginia.

Come Join Us!

Join the #1 WordPress Community and dive into conversations covering every aspect of running an agency!

Join Group

Kyle Van Deusen

Community Manager

Latest Events

September 16, 2025

Termageddon 2.0

Better Tools, Smoother Workflows, Happier Clients

August 19th, 2025

Which WordPress Page Builder is the Most Accessible?

The 2025 Page Builder Accessibility Report

August 15, 2025

Managing Your Agency with Moxie

Can this all-in-one solution help you streamline your agency and calm the chaos?
Care Plan Toolkit

Save time, boost profits, and confidently manage client websites with proven tools, tips, and resources.

Download Free
Bento Toolkit
The Friday Chaser

Wash down the week with the best of The Admin Bar! News, tips, and the best conversations delivered straight to your inbox every Friday!

Subscribe Today

More Articles

Cleanshot 2025 09 08 at 15.22.24@2x
September 10, 2025

Can you trust AI to write your website’s Privacy Policy?

Yes, AI can write your Privacy Policy — but chances are you (and the law) won’t like the result.

Barfly profile melodie moore
September 8, 2025

Member Spotlight: Melodie Moore

Melodie Moore didn’t start in tech—she started with hula hoops. What began as a professional hoop …

Drop rankings
September 4, 2025

Organic Traffic Dropped Suddenly? Here’s Why (And How to Fix It)

Seeing a sudden drop in your organic traffic? Don’t panic! Find out what causes organic traffic to decrease – from SERPs to technical issues – and how to fix it.

2025phone

Join the #1 WordPress Community

The Admin Bar community is at the heart of what we do. Join in on the daily conversation and get involved.

Request Membership
The Admin Bar logo.

Explore

Community

Events

Articles

Products

Newsletter

Agency Report Card

Care Plan Toolkit

Noted!

Barfly Login

Policies

Privacy Policy

Terms of Service

Affiliate Agreement

Affiliate Disclaimer

Accessibility Statement

Privacy Settings

Misc.

Advertise

Login

Contact

© 2017-2025 The Admin Bar (a Division of OGAL Web Design) — All Rights Reserved

The Admin Bar logo.
  • Get Involved
    • Facebook Group
    • Barfly Community
    • TABLE Mastermind
  • Learn
    • Articles
    • Events
    • Newsletter
    • YouTube
    • WordPress Professionals Survey
    • SEO Weekly
    • Security Weekly
    • Accessibility Weekly
  • Products
  • About
  • Free Stuff
YouTube Facebook
Sell More Care Plans