Pluginless maintenance mode w/ functions.php

I’m always looking for ways to ditch plugins to keep from bloating WordPress even more than I already do ;). I prefer working on a live server so I end up resorting to utilizing .htaccess to allow access to a specified IP addresses only. Using this snippet in functions.php is way easier since it just looks if a user can edit themes and if they’re logged in. Easy peasy!

Toss this into your functions.php file.

// Admin Access Only
function maintenance_mode() {
  if ( !current_user_can( 'edit_themes' ) || !is_user_logged_in() ) {
    die('Maintenance.');
  }
}
add_action('get_header', 'maintenance_mode');

Displaying posts for current day using a query

For the last week I’ve been working on a new project of mine that is a heavily modified calendar theme for WordPress that displays video game releases. The original concept of mine was using an actual calendar but after having some issues with how it displayed (basically just bad UX/UI) I nixed that idea. I decided that I would rather display all current releases for the current day.

So here’s the custom query to display posts for the current day. You can edit the query parameters to be as specific (or general) as you need them to be.

<ul>
<?php
$today = getdate();
query_posts('showposts=-1&post_status=publish,future&year=' .$today["year"] .'&monthnum=' .$today["mon"] .'&day=' .$today["mday"] );
while (have_posts()) : the_post(); ?>
<li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>
<?php endwhile; ?>
</ul>