[Resolved] Removing date on sticky blog post

Home Forums Support [Resolved] Removing date on sticky blog post

Home Forums Support Removing date on sticky blog post

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #2324626
    Emily

    Hello. Thank you for such an awesome theme!! It’s the only one I use. πŸ™‚

    Can you provide a little code snippet to hide the date on all sticky blog posts? The google was unable to provide an answer. If it’s easier to just hide all the meta, that works, too.

    Thank you!!

    #2324870
    Leo
    Staff
    Customer Support

    Hi there,

    Any chance you can link us to the page in question?

    You can use the private information field:
    https://docs.generatepress.com/article/using-the-premium-support-forum/#private-information

    Let me know πŸ™‚

    #2324875
    Emily

    Link to site in private info. The home page has a sticky post. We’re using WP Show Posts for the listing, but I’m hoping for a site-wide solution because we don’t want it to appear anywhere at all.

    #2324958
    Ying
    Staff
    Customer Support

    Hi Emily,

    Add this PHP code to your site so it adds the sticky-post class to the sticky posts.

    add_filter( 'post_class', 'sticky_post_class', 10, 2);
    function sticky_post_class( $classes, $class) {
    	
    	if (is_sticky()) {
    		 $classes[] = 'sticky-post';
    	     return $classes;
        }
        return $classes;
    }

    You can use either method mentioned here to add PHP: https://docs.generatepress.com/article/adding-php/

    Then we can use this CSS to target the sticky posts and hide the date:

    .sticky-post time.wp-show-posts-entry-date.published, .sticky-post .wp-show-posts-separator {
        display: none;
    }

    Adding CSS: https://docs.generatepress.com/article/adding-css/

    #2326589
    Emily

    Awesome! All set up. Thank you very much.

    #2327452
    Ying
    Staff
    Customer Support

    You are welcome πŸ™‚

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