5 Most Wanted Tips


5 Most Wanted Wordpress Tips

5 Most Wanted Wordpress Tips

There are times when you come across a feature in a blog, and you just start thinking to yourself: How can I get this in my WordPress blog/site as well. Everybody have experienced this feeling. Sometimes you know you want it, and don’t know where to look for, or even what to look for. In this article we will be sharing some of the most wanted WordPress Tips, Tricks, and Hacks that you will definitely find useful.

These tutorials are classified under various skills level. For some tutorials, you will need to know basic HTML and some WordPress Knowledge. Use the link below as one of your resources:

1- How to Displays Random Posts on Page


Maybe you have been seen on blogs this cool feature? They have a link in their top navigation to something like Stumbe! or Read Random Articles, or some other creative text. When you click on that link, it takes you to a page that displays one random page. Each time you refresh, you are delivered with a new post. Well this trick is just for you then.
You would need to follow the trick #1 in this article to create a custom page Themes. And simply paste this code in there:


    <?php
    query_posts(array('orderby' => 'rand', 'showposts' => 1));
    if (have_posts()) :
    while (have_posts()) : the_post(); ?>

    <h1><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h1>

    <?php the_content(); ?>

    <?php endwhile;
    endif; ?>

This is a simple WordPress Loop that is running a query to display random posts and the number 1 in there is telling WordPress to only show 1 post. You can change that number, but most of the time people do it one post a time.


2- Author’s Comment Highlight

Author’s Comment Highlight

May be you have seen this on blogs where author’s comments are grand from other comments? You know how it is? Well this is a simple and easy trick.

First of All you need to Edit your style.css in your Themes folder and add the following:
 
.authorstyle { background-color: #B3FFCC !important; } 

Then you need to Edit your comments.php which is also located in your themes folder and find the code that looks some what like this:

<li <?php echo $oddcomment; ?>id="comment-<?php comment_ID() ?>"></li>

Replace it with:

<li class="<?php if ($comment->user_id == 1) $oddcomment = "authorstyle"; echo $oddcomment; ?>"></li>


Note you must change 1 to the user id of the author. Once you do this, your blog comments will have a different background for the author’s comment compared to the rest.

3- As Text Display Twitter Follower Count


There are users who absolutely hate buttons like Feedburner buttons or Twittercounter buttons. Are you one of them? Do you want to display your twitter count as text, so it blends in to your new custom design? Well then this hack is just for you.
First you would need to create a file twitter.php and paste the following code in there:


<?php
$tw = get_option("twitterfollowerscount");
if ($tw['lastcheck'] < ( mktime() – 3600 ) )
{
$xml=file_get_contents('http://twitter.com/users/show.xml?screen_name=wpbeginner');
if (preg_match('/followers_count>(.*)</',$xml,$match)!=0) {
$tw['count'] = $match[1];
}
$tw['lastcheck'] = mktime();
update_option("twitterfollowerscount",$tw);
}
echo $tw['count'];
?> 


Make sure to replace wpbeginner with your twitter name.
Then Simply place this code anywhere you want to display this:

<?php include("twitter.php"); ?>

4- Change the Default Gravatar Button

The Default Gravatar Button

Say Good bye to default gravatar image The default gravatar image is really annoying for most users. Plus if you have one more chance of branding your blog, then why not do it. Changing your default gravatar lets you brand your blog more. With this snippet below you can change your default gravatar.


First you need to open your functions.php which is located in your template folder. If you don’t have one then create one and insert the following code:

    add_filter( 'avatar_defaults', 'newgravatar' );

    function newgravatar ($avatar_defaults) {
    $myavatar = get_bloginfo('template_directory') . '/images/gravataricon.gif';
    $avatar_defaults[$myavatar] = &quot;WPBeginner&quot;;
    return $avatar_defaults;
    }

In the code the image is being extracted from the theme directory and it is called gravataricon.gif obviously you will change it to your image name. Where it says Wordpress-tools.xyz, that is the name of the avatar of how it will show in your admin panel options area.

Say Good bye to default gravatar image

Head over to your admin panel and click Settings > Discussion and change the icon, and now you have a branded comment area with your logo.



5- Display Random Header Images in WordPress


Most blog designs get boring if they have a huge header picture and it is static. This is when this tutorial comes in to make your header images dynamic because it rotates on each visit. You can select as many images as you want to rotate randomly. It brings life to a blog.

First you need to name your images in this format:

  •  headerimage_1.gif
  •  headerimage_2.gif 
  •  headerimage_3.gif

You must separate the name with an underscore. You can change the headerimage text to himage or anything you like.

Once you have done that paste the following code in your header.php where you would like the images to be displayed or in any other file.

<img src="http://path_to_images/headerimage_<?php echo(rand(1,3)); ?>.gif"
width="image_width" height="image_height" alt="image_alt_text" />

Make sure that you change the number 3 if you decide to do more than 3 images.
This code is not exclusive for WordPress, it will work with any php based platform.

Related Posts

5 Most Wanted Tips
4/ 5
Oleh

Subscribe via email

Like the post above? Please subscribe to the latest posts directly via email.

-->