Support » Developing with WordPress » How To Make Blocks Disappear on Certain Date/Time

  • xMikeySlice


    Hey guys! I want to know how to get certain blocks to expire. I have match codes that expire, and would like them to disappear when they do. How can I do that? I’ve tried downloading plugins. It seems like the only plugin that was able to do this hasn’t been updated since 3 WordPress versions ago. The plugin is Post Expirator by Aaron Axelsen. Should I install it anyway? Or is there an better route?

    On the flip side I also would like the codes at the bottom to not appear until they’re working. Can I make those appear when the date/time comes? Thanks in advance guys!

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

Viewing 1 replies (of 1 total)
  • Moderator bcworkz


    A well written plugin can still function properly without being updated. Or it can fail horribly. It all depends on what it actually does. There’s a chance it will still work fine, but since it is no longer supported, it’s up to you to ensure it works as expected, and to correct any errors that may crop up. Not a good choice unless you have some PHP coding experience.

    My alternative suggestions also require either PHP or JS coding. One approach would be to schedule tasks through wp_schedule_single_event() that first adds in the desired HTML into existing content, then another event task to remove the same HTML at the specified time. Keep in mind that the tasks cannot be accurately scheduled to the minute. The event firing is dependent upon someone or something making a request to your site after the specified time before anything actually happens.

    Alternately, you could hook into “the_content” filter and have your callback insert the HTML if it is between the specified times. This could also be handled as a shortcode or editor block.

    Which to chose depends in part on if it’s important to have the correct content as it sits in the DB, or if it’s OK to correct the content on the fly when the post is requested.

Viewing 1 replies (of 1 total)
  • The topic ‘How To Make Blocks Disappear on Certain Date/Time’ is closed to new replies.