• Resolved aish547

    (@aish547)


    I want to make the category and links in the blog, search and archives in button/pill shape. I added this code, however, seems like it is not working.
    —–
    .cat-links, .tag-links {
    Design: Button;
    colour: Green;
    }

    • This topic was modified 2 years, 4 months ago by aish547.

    The page I need help with: [log in to see the link]

Viewing 9 replies - 1 through 9 (of 9 total)
  • ying

    (@yingscarlett)

    Hi there,

    Something like this would be a good start:

    .entry-meta a {
        background-color: #000;
        padding: 5px;
        border-radius: 5px;
        margin-top: 5px;
    }
    Thread Starter aish547

    (@aish547)

    Works.

    But how to remove icons and commas? It looks gross.
    And the text color to black.

    ying

    (@yingscarlett)

    1. You can try this filter to change or remove the comma:
    https://docs.generatepress.com/article/generate_term_separator/

    In your case, the code would be:

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

    2. This CSS to hide the icon:

    .blog footer.entry-meta span:before, .archive footer.entry-meta span:before {
        content: "";
    }

    3. Add one more line to your CSS selector .entry-meta a:
    color: black;

    Thread Starter aish547

    (@aish547)

    Thanks!

    The code works for blog page.

    But for single post/blog, it is not working.

    Check at: https://lawbhoomi.com/law-college-search/the-department-of-law-sri-krishna-university/

    ying

    (@yingscarlett)

    Hum.. you didn’t mention the single post in your original topic, so my CSS was targeting the blog and archives specifically.

    If you want it to apply to your single posts as well, change NO.2 CSS in my last reply to:

    footer.entry-meta span:before{
        content: "";
    }
    Thread Starter aish547

    (@aish547)

    You are right! I did miss it!

    The code works.

    Thanks!

    But, what about commas the category links (and tags links to be added soon) just below the title?

    I have added them using the following filter:

    add_action( 'generate_after_entry_title', 'lh_add_cat_below_title' );
    function lh_add_cat_below_title() {
        if (is_single() ) {
            $categories_list = get_the_category_list( _x( ', ', 'Used between list items, there is a space after the comma.', 'generatepress' ) );
            $categories_list = sprintf( '<span class="cat-links"><span class="screen-reader-text">%1$s </span>%2$s</span>',
                _x( 'Categories', 'Used before category names.', 'generatepress' ),
                $categories_list
            );
        }
    
        ?>
        <div class="entry-meta">
    	<?php echo $categories_list; ?>
        </div>
        <?php
    }
    ying

    (@yingscarlett)

    In that case, change your code to:

    add_action( 'generate_after_entry_title', 'lh_add_cat_below_title' );
    function lh_add_cat_below_title() {
        if (is_single() ) {
            $categories_list = get_the_category_list( _x( ' ', 'Used between list items, there is a space after the comma.', 'generatepress' ) );
            $categories_list = sprintf( '<span class="cat-links"><span class="screen-reader-text">%1$s </span>%2$s</span>',
                _x( 'Categories', 'Used before category names.', 'generatepress' ),
                $categories_list
            );
        }
    
        ?>
        <div class="entry-meta">
    	<?php echo $categories_list; ?>
        </div>
        <?php
    }
    Thread Starter aish547

    (@aish547)

    Thanks!

    ying

    (@yingscarlett)

    No problem ??

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Change Design of the Category and tag links’ is closed to new replies.