It's random, too damn random.


Snap569 Has Arrived Blog

February
28
2009
Posted by Shaibani | Tags: ,

Just wanted to say that Snap569 Coding has moved to http://random-is.me/code. :-)

Loading Timer Code

February
14
2009
Posted by Shaibani | Tags: , ,

I’ve got a few people asking about how I got the seconds it took the page to load to display. Just wanna share the code:

1
<?php timer_stop(1); ?>  <?php echo $db->num_queries; ?>

Or you can simply use:

1
<?php echo('text before time' . timer_stop(0) . 'text after time'); ?>

HTML is allowed in text before time and text after time.

Works in a WordPress environment only. :-)

A Few SEO Tips List

February
14
2009
Posted by Shaibani | Tags: , , ,

Search Engine Optimization (SEO), is well self-explanatory. I shouldn’t have to explain what it is, but I will! SEO is simply moving up in the search engine rankings. Hopefully search engines will like you more after you make use of this post. On with my tips:

  1. Use Headers Correctly

    By headers I mean <h1>, <h2>, <h3>, <h4> and so on. What you should have is 1 <h1> tag, 10-15 <h2>, and as many as headers your sidebar needs for <h3>. Confused? I’ll explain. <h1> tags should have the website’s/webpage’s title (eg. Random-is.me). <h2> tags should have the description (if any) (eg. It’s random, too damn random) and the post titles. <h3> tags should be used for sidebar titles.

  2. Meta Tags

    Make sure you have a description, keywords, author etc. If you don’t have them, Google meta generator.

  3. Search Engines Don’t Have Eyes

    Sadly they don’t. So use alt="image of something" for images and title="image of something" for images, links, titles, headers etc.

  4. Validate.

    No I’m not kidding, search engines prefer it. :-D

Got your own tips to share? Go ahead. ;)

wp_logout_url Code

February
13
2009
Posted by Shaibani | Tags: ,

Well as you may have seen, I’ve been changing themes quite frequently in the last few days. I decided to go back to Resurrection (my theme), and as I was looking through the comments code, I found this:

1
<p>Logged in as <a href="<?php echo get_option('siteurl'); ?>/wp-admin/profile.php"><?php echo $user_identity; ?></a>. <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?action=logout" title="Log out of this account">Log out &raquo;</a></p>

What’s wrong with that you ask? If you’re on WordPress 2.7 (you better be), you’re gonna have a problem. In WordPress 2.7, you’ll notice there’s a wpnonce=x (x being random figures and letters) added to the logout URL. How do I get that when there’s a random figure there? Simple:

1
<p>Logged in as <a href="<?php echo get_option('siteurl'); ?>/wp-admin/profile.php"><?php echo $user_identity; ?></a>. <a href="<?php echo wp_logout_url(); ?>" title="Log out of this account">Log out &raquo;</a></p>

See the difference? It’s the echo wp_logout_url();. That function gives you the whole URL with the wpnounce. :-)

date Instead of the_time Code

February
6
2009
Posted by Shaibani | Tags: , ,

Last month, I published a post about the WordPress functionthe_time('Y') and the PHP function date('Y')

Well as I was browsing through a few old posts, which were published in 2008, I noticed that the year date in the footer changed back to 2008. I changed it to

1
<?php echo date('Y'); ?>

Then it stayed as 2009! By the way, I know this can be figured out through common sense, but some lack it, this is obviously for disclaimers, footers etc. – NOT for posts.

the_date and the_time tags Code

December
22
2008
Posted by Shaibani | Tags: ,

You know, for a while I thought the_date for WordPress was 100% good… Them I found out it sucks! Sometimes it doesn’t show, sometimes it shows up in different formats so here’s what I’ll use from now on…

1
<?php the_time('F j, Y'); ?>

Output: December 22, 2008

Simple, and easy. :-)

phpinfo Code

December
22
2008
Posted by Shaibani | Tags: ,

How to make your own phpinfo page…

Simply create a .php page and add this to it:

1
<?php phpinfo(); ?>

How simple… :-)

Year PHP Code II Code

December
13
2008
Posted by Shaibani | Tags: ,

You may have read my previous post — Year PHP Code. Here’s an extra thing…

What if you wanna display the next year? You add the following…

1
<?php echo date ('Y') + 1; ?>

Output: 2011
When it does turn 2011, it will automatically change to 2012!

You can change the + 1 to any number that suits your needs!

Year PHP Code Code

December
2
2008
Posted by Shaibani | Tags: , , ,

EDIT: date Instead of the_time

If you wanna use the current year for a copyright statement or whatever and not have to update it every year (if you’re that lazy :P ) Here’s how:

If you’re in a WordPress environment:

1
<?php the_time('Y'); ?>

Output: 2008
(Yes, I can execute PHP in my posts.)

And in any normal .php page, you can get the year from your server.

1
<?php echo date('Y'); ?>

Output: 2010
So on exactly 31/12/2008 11:59, it’ll be 2010, and the next minute, well.. you know what’s gonna happen. :-)

Iframes Out, PHP In Tutorials

August
30
2008

Rate: MehNot badVery goodPerfect! Loading ... Loading ...
Yes, you heard me, Iframes out. Yes a site can work without them. Calm down :-| Why would you wanna get rid of Iframes?
1. They’re old
2. Too “limiting”
3. Its harder to get on Google etc. with them.
4. They’re un-professional IMO.

So we’re gonna get rid of them using PHP :-D
Note: Remember to save all your files that use this method with the .php extension.
(more…)

Get Adobe Flash playerPlugin by wpburn.com wordpress themes