Home › Forums › Support › Assign custom color to (entry meta) category links bg & add avatar to byline
- This topic has 8 replies, 2 voices, and was last updated 3 years, 4 months ago by Elvin.
-
AuthorPosts
-
December 9, 2020 at 2:35 pm #1573589Goran Dragutinovic
Hello, I am looking to assign custom colors to my entry meta category links, so:
– Category 1: Blue
– Category 2: Yellow
– Category 3: Red
– etc.I am also looking to add a custom avatar image before the author byline.
All help is appreciated.
December 9, 2020 at 4:38 pm #1573665ElvinStaffCustomer SupportHi,
Can you link us to the page you’re working on?
You can provide the site details on the private information textfield. Thank you.
December 9, 2020 at 4:56 pm #1573679Goran DragutinovicSure things, here it is.
December 9, 2020 at 5:43 pm #1573697ElvinStaffCustomer SupportHello, I am looking to assign custom colors to my entry meta category links, so:
For this, you can do CSS styling using its element’s attribute.
Example: for “Shows” category.
span.cat-links a[href*="/shows"] { background-color: blue; }
Simply add more of this for each category you want to style.
More examples:
Example: for “Movies” category.
span.cat-links a[href*="/movies"] { background-color: green; }
I am also looking to add a custom avatar image before the author byline.
You can check this brief documentation on how to add avatar image before the author byline.
https://docs.generatepress.com/article/entry-meta-style/#example-1December 10, 2020 at 9:37 am #1574636Goran DragutinovicUgh can’t believe I didn’t think of that! Thanks Elvin, that did it.
Do you have the link on how to remove the commas between the category links by chance?
I saw it somewhere on here but I can’t find it now.
December 10, 2020 at 3:36 pm #1575016ElvinStaffCustomer SupportYou’ll have to use the
generate_term_separator
for that.Example:
add_filter( ‘generate_term_separator’, function() {
return ”;
} );But this will apply for the tag links as well. If you want to change it for the category links only, you’ll have to changes its output with
generate_category_list_output
filter.December 10, 2020 at 3:36 pm #1575017ElvinStaffCustomer SupportYou’ll have to use the
generate_term_separator
for that.Example:
add_filter( 'generate_term_separator', function() { return ''; } );
But this will apply for the tag links as well. If you want to change it for the category links only, you’ll have to changes its output with
generate_category_list_output
filter.December 10, 2020 at 4:13 pm #1575052Goran DragutinovicThanks Elvin, yeah so the:
add_filter( 'generate_term_separator', function() { return ''; } );
does the trick for the tag links, but not for removing the comma between category links on the homepage.
This:
add_filter( 'generate_category_list_output', function() { return ''; } );
did not seem to work in removing the comma from the homepage either.
I’ll await your reply, as of right now I just changed the functions.php line where the comma is being inserted and left it as a space instead.
Thanks for your help.
December 10, 2020 at 5:21 pm #1575090ElvinStaffCustomer Supportdoes the trick for the tag links, but not for removing the comma between category links on the homepage.
Strange, that’s suppose to work for both.
Try this for the category separator:
add_filter( 'generate_category_list_output', function() { return sprintf( '<span class="cat-links">%3$s<span class="screen-reader-text">%1$s </span>%2$s</span> ', esc_html_x( 'Categories', 'Used before category names.', 'generatepress' ), get_the_category_list( ' ' ), apply_filters( 'generate_inside_post_meta_item_output', '', 'categories' ) ); } );
get_the_category_list( ' ' )
means its using space as a separator.get_the_category_list( '|' )
means its using|
as a separator. Feel free to adjust it to your preferred separator or just keep it as is if you only want spaces. -
AuthorPosts
- You must be logged in to reply to this topic.