Support » Fixing WordPress » Adding CSS Class to post after 1 month

  • Hi,

    I would like to add a CSS class to a post, 1 month after it has been published. As I want to hide some elements of that post, after it has been live for one month.

    Could someone please help in how I can do this?

    Thank you!

Viewing 4 replies - 1 through 4 (of 4 total)
  • just a single post or all post ?? If it all post you can create a child theme and just add it in the single.php file. If it just a single post you can do it by creating a file single-<<post>>.php. Really depends on what you want to do. You can’t just add it to the current theme or it will be overwritten if the theme updates. Either way you are probably looking at creating a child theme.

    You just have to copy single.php and paste it into your child theme and make the changes you want then save it under the correct name.

    • This reply was modified 2 years, 3 months ago by mrtom414.
    Thread Starter scott0102

    (@scott0102)

    For all posts, so every single post will have hidden divs after 1 month.

    Thanks

    if you put it in single.php all post with exception of ones who declared their own single. example single-professor would not be included.

    Moderator bcworkz

    (@bcworkz)

    That’s fine for individual single post pages, but what about archive listings of various sorts? If you want to manage the post display on these pages you need to go beyond single.php. The specifics depend on your theme.

    You are probably aware, but it warrants pointing out for the record that hiding elements with CSS does not prevent users from discovering the hidden content by viewing the page source. If the hidden elements must be securely hidden, it must be done server side with PHP.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Adding CSS Class to post after 1 month’ is closed to new replies.