[Resolved] Post Tag Styling

Home Forums Support [Resolved] Post Tag Styling

Home Forums Support Post Tag Styling

  • This topic has 11 replies, 4 voices, and was last updated 9 months ago by Elvin.
Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #1639923
    Leighton

    Hello!

    I’m trying to style my post tags at the bottom of the post to achieve this look with added hover styling:
    Original Style: https://imgur.com/GcwmzXD
    New Style: https://imgur.com/rvp1vi0
    Staging Post for Reference: https://wordpress-538093-1730059.cloudwaysapps.com/best-laptops-for-college-students/

    This is the code I used.

    .gp-icon.icon-tags {
    	display: none!important;
    }
    
    .tags-links:before {
    	content: 'Tags: ';
    	font-weight: 700;
    	margin-right: 10px;
    }
    
    .tags-links a {
    	background-color: #f5f5f5;
    	color:#000;
    	font-size: 14px;
    	font-weight: 400;
    	padding: 2px 7px;
    }
    
    .tags-links a:hover {
    	background-color: #3380ff;
    	color: #fff;
    }
    

    Is this code correct? Any potential issues?

    My main problem is how do I get rid of the comma separators? I can’t figure that one out.

    Thanks!

    #1639932
    Leo
    Staff
    Customer Support

    Hi there,

    The code looks good to me.

    Try this to remove the comma:
    https://docs.generatepress.com/article/generate_term_separator/

    add_filter( 'generate_term_separator', function() {
        return '';
    } );

    Adding PHP: https://docs.generatepress.com/article/adding-php/

    Let me know if this helps πŸ™‚

    #1639966
    Leighton

    Works perfectly! Thanks again

    #1640003
    Leo
    Staff
    Customer Support
    #1999519
    Simon

    Hi, how can we apply this filter only on the Post Page ?

    add_filter( 'generate_term_separator', function() {
        return '';
    } );

    Thank you

    #1999527
    Elvin
    Staff
    Customer Support

    Hi Simon,

    Try this:

    add_filter( 'generate_term_separator', function() {
    if( is_single() ){
        return '';
    }
    } );

    A wise man once said:
    "Have you cleared your cache?"

    #1999545
    Simon

    When i add if( is_single() ){ , the comma is also removed on blog category page, i would like to remove it only on the blog post page

    Thank you

    #1999548
    Elvin
    Staff
    Customer Support

    Strange. That should’ve worked.

    Can you try this instead?

    add_filter( 'generate_term_separator', function($separator) {
    if( is_single() ){
        $separator = '';
    } 
    
    return $separator;
    },15,1);

    Can you link me to a sample single post page and the supposed blog index of the site in question? To check the actual query type of the pages.

    A wise man once said:
    "Have you cleared your cache?"

    #1999556
    Simon

    Working well, thank you (bow)

    what is the 15,1 ?

    #1999572
    Elvin
    Staff
    Customer Support

    Those values are hook priority (15) and values to be accepted by the function (1 which is the $separator). πŸ˜€

    A wise man once said:
    "Have you cleared your cache?"

    #1999574
    Simon

    thanks 😎

    #1999581
    Elvin
    Staff
    Customer Support

    No problem. πŸ˜€

    A wise man once said:
    "Have you cleared your cache?"

Viewing 12 posts - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.