-
markmapstone
Hi.
I would like to show category meta data on a News Index page, but show nothing if a category isn’t selected.
Here’s what I’m trying to do:https://markmapstone.com/wp-content/uploads/2023/11/Art-in-Schools-category.jpg
Here’s a screenshot of the page I’ve created:
https://markmapstone.com/wp-content/uploads/2023/11/My-page.jpgThe site is only local atm, so I can’t share a functional link.
Can I do this within the GP/GB pro suite?
Thanks
-
Hi there,
is the News page a static page ? ( it kinda needs to be 🙂 )
-
markmapstone
Yes the News page is static, but the feed is part of a query loop.
-
Fernando
Hi Mark,
Can you clarify this part “but show nothing if a category isn’t selected.”?
When you say “selected”, where are you selecting a category exactly?
-
markmapstone
Sorry, maybe selected is the wrong word. I mean assigned, or allocated.
In my first image I have a regular query loop for a newsfeed, and on it I want to indicate a red badge (and/or button/link) to show a news item is also part of another category called ‘the art in schools’.
So I’m looking for a way to show and style a category, but not all categories on a news queryloop.
My second screenshot shows all categories being displayed, but I don’t want that. I need just the one category shown.
-
Fernando
I see. We can do that through custom CSS.
Remove the styling you’re adding the “all categories” in your Query Loop, and share the link to this News Page after.
We’ll help you with the CSS.
-
markmapstone
Thanks. See the page here: https://mapst.one/latest/
-
If the main style change for that category term is the color then i would do this:
1. in GP Customizer > Colors, add a new global color, give it a name like
term-color
and give it a transparent background.Behind the scenes GP will create a CSS variable called:
--term-color
with a value likergba(0,0,0,0)
2. Now edit the Query Loop you want to style, and select the Term Headline block and:
2.1 set its Background color to your new term-color
2.2 give the block an Advanced > Additional CSS Class of:dynamic-term
– this just for future proofing inc case we need extra styles.3. No add this CSS to your site:
.category-the-art-in-school { --term-color: var(--accent); }
So what the CSS does is:
i) each post is given classes including the category term class.
ii) reload the term-color value ( which is transparent ) with your--accent
color.
iii) but only where thecategory-the-art-in-school
exists -
markmapstone
Perfect. That’s sorted it. Thanks 😀
-
Glad to hear that
- You must be logged in to reply to this topic.