Posts tagged WordPress

Contact forms for your blog:

0

You have a blog and want traffic don't you? Well of course, since that is what makes us blog in the first place! The readers might like to read our stuff, and many times they want to talk to us, and contact forms are really good at that ;)
What I mean is that it is no breaking news that contact forms are actually used, either by potential customers, readers that want to share/correct us or simply by someone who dropped by and wants to say "Hey, nice design".
Whatever the reason is, it is always good to have a contact form, and when I wanted to setup mine I looked for WordPress plugins to do it for me (I'm a bit lazy in that sense) and found some interesting stuff.

First of all we have cForms which if I had to explain it to someone that knew nothing about this I would simply say, "if you install cForms for your contact form is like wanting to buy a computer simply to browse the web and buying a gaming computer that is the closest thing to a supercomputer one could find". I mean by this that cForms is too much for the average blogger, it has too many things, the first time I saw it I just though "Can I just have a contact form please?", although I ended up liking it.

So if you just want a contact form, good and simple, there are many good plugins out there that do the job perfectly,

Contact Form ][:

Which, as they say, "[it] is a WordPress plugin, that offers a simple drop-in contact form in any new/existing post/page". It is a nice plugin although you will never get any support from the author, so be careful on this one.

Contact Form Plugin:

This plugin changes a bit how the contact forms work, instead of entering a tag withing the content of a page/post, you publish it, and then you paste the URL into the configuration page, a bit weird yes, but in the end it is just as simple.

There are of course many other options available, although this are the most varied ones. What is your favorite?

Display previous/next posts in single, category… in WordPress

0

This is a really good option in WordPress, yet very few know how to do it. Well the code is relatively simple, and it gives a good navigation point for users that, if they liked your article, might want to keep reading your stuff.

If you want to plainly display the next post after the one the user is reading, use the following function:

 
< ?php next_post_link(); ?>
 

Now this function has several (very useful) parameters, which are:

 
 < ?php next_post_link('format', 'link', in_same_cat,
                         'excluded_categories'); ?>
 

Format: For example bold ('%link'), italics ('%link')... And so on, you can add here divs, p, span or anything you want to apply css classes or ids.

Link: To display a custom text instead of the post title, for example if you want "Next post" use:

 
< ?php next_post_link('%link', 'Next post in category', TRUE); ?>
 

in_same_cat: A very handy parameter if you want to display only the next post of the same category. Set to TRUE if you want it that way, or FALSE if you simply want the next post.

You can use one more parameter to exclude categories, for example:

 
< ?php next_post_link('%link', 'Next post in category', TRUE, '13'); ?>
 

And now the next post will be from the same category, unless that category is 13 (The id, check in the administration panel)

If you want to exclude multiple categories you'll have to use the "and" separator. It will work like this:
'1 and 5 and 15'
Note: If you are using WordPress 2.2, the concatenation method was a comma (','). So you would use:
'1,5,15'

Of course to display previous posts substitute next by previous, with everything else being the same.

Enjoy,

Easily assign an image to a post in WordPress

1

Have you ever wondered how to assign an image to a certain post using WordPress? Surely there are some plugins that try to do this, and maybe they accomplish it, but probably slowing down your blog.

Well, here is a way of doing it without slowing the blog or installing any sort of additional plugins. When you are done writing your post, upload an image to a directory that you will use for this, for example: "www.yoursite.com/post_images/". And I recommned that you name the image something that has to do with the post, it will help you if you need to edit it.

Now in the writing are scroll down until you see the tab "Custom fields":

Assigning images to posts

And fill in the following information:

Key: post_image
Value: image_name.jpg

The key must be always the same, in this example it will be post_image. And the value will be the name of the image that we uploaded. In the example it is assigning_images.jpg

And that's it for now. The next step is including this images into our template.

Add the image to the template:

As you can see under the tab Custom Fields there is a link to the WordPress codex, where they explain the functions we'll use for this, so consult that if you have any doubts.

So here is the code to display the image (It must be inserted inside the Loop):

 
if(get_post_meta($post->ID, 'post_image',true)){
	//There is an image assigned:
	echo '<img src="http://yourblog.com/post_images/'.get_post_meta($post-/>ID, 'post_image',true).'" />';
}
 

Note that if you copy and paste the code before you'll have to delete a / in $post->ID because WordPress is adding it automatically.
Of course this is the most basic approach, but hopefully you will understand the method and will be able to work on it.
At the moment I am using it to display thumbnails on the archive excerpts (They are not live yet, I'm still testing) and it is a very easy and fast way of doing it.

If you ever need to edit either the image or the meta-data simply re-upload the picture or edit the post.

Cheers,

Best wp plugins for administrators

4

As some of you might know, I've just "upgraded" my design, now it is completely different... Hope you like it ;)
And in the process I came along with many great plugins that really made my life easier in this task, so I'll post a compilation not only of those, but of the best administration plugins at the moment:

  • Design:
  • Maintenance/Upgrading
    • Maintenance mode - Put a splash page for all visitors except administrators. Great for testing new stuff.
    • WP Automatic Upgrade - Backup and Upgrade your wordpress version automatically.
    • Theme tester - Test your new themes without users noticing.
    • Role Manager - Edit the capabilities of each wp role (Admin, editor, author or suscriber) or even add new roles.
  • Security:
    • WP Security Scan - This great plugin checks for various vulnerabilities and either fixes them or tells you how to DIY.
  • Stats/Counters
    • StatPress - For me the best wp statistics plugin.
    • Download counter - Tired of not knowing if people really download your stuff? You'll love this plugin if that was the case...
    • Google Analyticator - If you want to stick with good old Google Analytics, then this is your plugin.
  • SEO
  • Comments:
    • Ozh' Absolute Comments - A great plugin to manage your comments, you should really try this to know what you are missing ;)
    • WP Threaded Comments - In addition to Ozh' Absolute Comments this will ease the way you deal with comments, allowing you to reply to messages in threaded mode right from the post itself.
    • Subscribe to comments - Give your visitors the opportunity to suscribe to the comments to get instant notification upon replies.

Using Gravatars in your blog comments

0

GravatarI'm sure you have seen in some blogs or websites that as soon as you enter your email, or other people do, an avatar is displayed for them. If you haven't still set your own you should do that now.
A Gravatar is a "Globally Recognized Avatar", meaning that anyone can display yours if they know your email address. The good thing for you bloggers out there is that you could use that to display avatars in the comments of your blog, or you could implement it in your forum, or virtually in any website that uses avatars.

I will explain how to do this in a general way, and then some tips for some CMS like WordPress, MovableType...

General Implementation

PHP

Using Gravatars in php is as simple as follows:
First set up the configuration variables

 
$email = "someone@somewhere.com";
$default = "http://www.somewhere.com/homestar.jpg";
$size = 40;
 

Now construct the Gravatar code:

 
$grav_url = "http://www.gravatar.com/avatar.php?
gravatar_id=".md5($email).
"&default=".urlencode($default).
"&size=".$size;
 

And you are ready to go!

 
<img src="<?php echo $grav_url; ?/>" alt="My Gravatar" />

Of course you can build your own function to do this:

 
function gravatar($email,$default,$size){
        $grav_url = "http://www.gravatar.com/avatar.php?
        return gravatar_id=".md5($email).
        "&default=".urlencode($default).
        "&size=".$size;
}
 

And that is pretty much it for PHP

Other languages

Visit the documentation site at gravatars.com to find out, or click on the links below:

  1. Perl
  2. ColdFusion
  3. Java

Installation in blogging software

WordPress

To use in WordPress there is a plugin available that will simplify the whole process a lot for you.
First of all download and activate the plugin.
What this plugin does is it will allow you to easily call the gravatar functions from the comments loop, without worrying for any special code. For a simple insertion just use:

 
<img src="<?php gravatar(); ?/>" alt="Gravatar" />

And you've got it.
You can personalize this as follows:

  1. First parameter will determine the minimum rating for the gravatar (G, PG, R, X)
  2. Second parameter is the height/width (They are the same ). Default is 80
  3. Last parameter is the default image, if not set gravatar will display their logo.

So a gravatar call with all parameters would look like this:

 
<img src="<?php gravatar("R", 80, "http://urbanoalvarez.es/img/blog/gravatar.png"); ?/>" alt="Gravatar"  />

In order to successfully implement it you need to put the codes above in the comments loop. I'll post my own comment loop code to let you see how it is constructed and displayed:

 
< ?php foreach ($comments as $comment) : ?>
<li <?php adminClass(apply_filters('comment_author',get_comment_author()),$oddcomment) ?>id="comment-< ?php comment_ID() ?>">
                        <a href="http://en.gravatar.com/"><img src="<?php gravatar("R", 80, "http://urbanoalvarez.es/img/blog/gravatar.png"); ?/>" alt="Gravatar" align="right" class="gravatar" /></a>
<div><cite>< ?php comment_author_link() ?> says:</cite>
			< ?php if ($comment->comment_approved == '0') : ?>
			<em>Your comment is awaiting moderation.</em>
			< ?php endif; ?>
 
 
			<small class="commentmetadata"><a href="#comment-<?php comment_ID() ?>" title="">< ?php comment_date('F jS, Y') ?> at < ?php comment_time() ?></a> < ?php edit_comment_link('edit','&nbsp;&nbsp;',''); ?></small>
 
			< ?php comment_text() ?></div>
</li>
 
	< ?php
		/* Changes every other comment to a different class */
		$oddcomment = ( empty( $oddcomment ) ) ? 'class="alt" ' : '';
	?>
 
	< ?php endforeach; /* end for each comment */ ?>
 

Other blogging software

There are several plugins and guides on the usage of the gravatars for most major blogging softwares, so go to the implementation page and browse for yours.

For any problems regarding installation/usage please don't hesitate to contact via the comments at the bottom of the page

Go to Top