Posts Tagged ‘Js’

How do I add the date to my blog?

There are a lot of times when we want to add something as simple as the date to our blog but coding (especially in PHP) can be a bit difficult. Let me walk you through the steps to adding a date to your blog, assuming of course you use WordPress.

First, open your template files such as the footer by loading the footer.php file located in your /wp-content/themes/[theme name]/ folder.

Next, we need to insert a very simple PHP function called date() into your page but before we do that, we need to make sure that we open and close the PHP event. To do this, simply open it using <?php and close it using ?>. The date() function itself requires a formating argument, but luckily we’re not meant to remember them all. They can be found on the PHP date() reference page.

As an example, if you want to show the day of the week that it currently is you could open your website and edit it every day (highly impractical) or you could insert the code <?php echo date(‘l’); ?> into your page. Note that I open the PHP event, place the date() function with the argument ‘l’, indicate the end of a line (;) and then close the PHP event.  Each of these elements are required to properly format the date.

If you would like to show the current year, simply use: <?php echo date(‘Y’); ?> because Y is the symbol for the year. On the other hand, if you’d like to use something more complex, try <?php echo date(‘l jS \of F Y h:i:s A’); ?> which will return something like Monday 8th of August 2005 03:12:46 PM.

Once you’ve saved your footer.php file, simply re-upload it to your server and voila! Now you can set the date using your server and PHP instead of editing files every day! In more practical terms, it is how you can always have an updated copyright notice of your website without having to remember to update it each January.

10 WordPress Plugins I Couldn’t Run a Site Without

Before I give you my real list, let me tell you that there are some basics that don’t even deserve to make this list because if you’re running a blog without them, you’re simply working too hard. Plugins like Askimet, WP Lockdown, Theme Switcher, WordPress.com stats, the WordPress.com stats smiley remover and WordPress Database Backup.

Delete Duplicate Posts WordPress Plugin

Simply put, this plugin does exactly what it’s name implies. It gives web masters like me the opporunity to quickly scan tens of thousands of postings in databases to ensure there are no duplicates. It’s wonderfully powerful when you have a thousands of feeds to maintain, and only a few hours to do it in. It also happens to be from my close friend, Montreal web designer Christopher Bavota.

WP Auto Tagger

Oh man … I can not stress what a dream this plugin is. Tags are like keys to SEO gold, they’re one of the few things that a blog owner can do well and immediately see amazing results in the search engines but they’re such a pain in the ass to write. Basically a tag is what your article is about, but in popular single words and catch phrases. What WP Auto Tagger does is great, it breaks down your article and suggests the best tags, automatically. That’s a huge time saver.

Syntax Highlighter

This bad bay is the Jonas brothers of WordPress plugins. Sure it’s fairly pointless and a text editor could do the same job but when it comes to saving time (and money) it’s brilliant. What it does is takes a bunch of rough gobbly gook code like this:

$rss = fetch_rss( $url );
$pcount = 0;
$storycount = 0;
$textdate = date(“F jS”, mktime(0, 0, 0, str_pad($month, 2, “0″, STR_PAD_LEFT), str_pad($day, 2, “0″, STR_PAD_LEFT), $year));

echo $textdate;
foreach ($rss->items as $item) {

if (!$first) {$title = $item['title'];$first=1;

$content .= “<h3><a href=’”.$item['link'].”‘ title=’”.$item['title'].”‘>”.$item['title'].”</a></h3>”;
$content .= “<p>”;

if ($item['link_enclosure']) {
$content .= “<a href=’”.$item['link'].”‘ title=’”.$item['title'].”‘><img alt=’”.$item['title'].”‘ src=’”.$item['link_enclosure'].”‘ class=’alignleft’></a>”;
}

and turns it into …

[source lang="php"]$rss = fetch_rss( $url );
$pcount = 0;
$storycount = 0;
$textdate = date("F jS", mktime(0, 0, 0, str_pad($month, 2, "0", STR_PAD_LEFT), str_pad($day, 2, "0", STR_PAD_LEFT), $year));

echo $textdate;
foreach ($rss->items as $item) {

if (!$first) {$title = $item['title'];$first=1;

$content .= "<h3><a href=’".$item['link']."’ title=’".$item['title']."’>".$item['title']."</a></h3>";
$content .= "<p>";

if ($item['link_enclosure']) {
$content .= "<a href=’".$item['link']."’ title=’".$item['title']."’><img alt=’".$item['title']."’ src=’".$item['link_enclosure']."’ class=’alignleft’></a>";
}
[/source]

When it comes to saving time, that’s a huge helper.

WP Super Cache

It simply terrifies me how many people are not running this plugin or a similar flavor of it. It makes your site safer, easier to manage and much faster for the end user. I’ll also mention that by running it you can use a host like BlueHost for $7.95 a month to run dozens of websites instead of spending hundreds a month to run just one site on complex, over priced servers.

Enforce www. Prefix

Actually, I’m going to cheat here and tell you that this and Canonical URL’s are plugins you should have for massive SEO curb appeal. Basically Enforce www. Prefix forces your website to always use the correct SEO address and Canonical URL’s tell’s Google that your article is the source, so even if people repost it you get credit.

Google XML Sitemaps

We all want Google to come to our site right? Well, let’s make it easy for them! Sitemap will provide Google with a free pass to all your content, no matter how deep your links are.

Get Image from Post

People love pictures and with this simple plugin your website will be able to post pictures as part of your excerpt. Speaking of excerpts, Get Better Excerpts will allow you to pull complete sentences or words from your excerpts.

SEO Friendly Images

Between this and SEO Smart Links, I’ll be honest most websites are on auto pilot. The SEO Friendly Images ensures your images have the proper tags to make the most of search engines, while Smart Links adds valuable data to your hyperlinks.

WordPress Admin Quick Menu

quickmenu 10 WordPress Plugins I Couldnt Run a Site Without imageI might be a little bias but this is truly my favorite plugin. It allows you to add your own menu items to the WordPress Admin client, basically creating shortcuts between your website and important things like AdSense and Analytics. It’s completely customizable and saves endless frustrations between myself and clients but providing them immediate access to critical links.

Download Counter

Just like Analytics lets you know who’s visiting and where they’re going, you’ll want to track what people are downloading from your website and how often. This saves a fortune in report generation time, by simply allowing me to tell my clients weekly how often software has been downloaded.

My Favorite WordPress plugins

Without a doubt, this is one of those topics that WordPress developers love to share, but for me it’s about more than simply spouting out a list of popular WordPress plugins, I really do love using these plugins because they make my life easier.

Akismet

This goes without saying, Matt Mullenweg did a brilliant job on this plugin and it’s become a staple that every WordPress blog should use. Link to Akismet

Frame Buster

This is a great plugin by Denis de Bernardy which basically stops sites like about.com from loading your content into their frames and keeping their banner at the top. Link to Frame Buster

Lightbox

A simple plugin both to install and to use, the Lightbox plugin by Peppe Argento uses Lightbox JS by Lokesh Dhakar to display image zooms on your site. Light Box

WordPress Mobile Edition

Alex King did a great job on this little plugin that makes your website more compatible with mobile devices. Mobile Edition

Thumbnail For Excerpts

For years I struggled with how to quickly add images to my excerpts but Radu Capan introduced a fantastic plugin that searches your posts and finds the first image. Thumbnails for Excerpts

Text Replace

Last but not least, I can’t say enough great things about Scott Reilly’s text replace plugin for WordPress. It searches your posts and replaces text with strings, so each time a specific phrase appears (such as WordPress) it automatically creates the hyperlinks for me. Text Replace