Blog |

WordPress for Beginners – Interesting Tips and Tricks

Posted by on Thu, May 30, 2013

2 Comments

Over the years, WordPress has taken the world by storm. What started as a nice looking CMS has turned into a complete development system with widgets, plugins and templates allowing advanced functionalities. It has grown into a complex and sophisticated system that many newcomers find a bit tricky to understand. But thanks to the immense popularity and advancements in WordPress development, honing your skills and learning new tricks have become easier that can serve you really well in the creation of your next WordPress blog or a WordPress CMS.

1)      Use Custom Page as your Homepage in WordPress

This is one of the most wanted hacks that the WordPress developers want to know. For this, first you need to learn and then create a custom page. When you have done that, you will need to make a copy of your .php page or simply create a new .php file and then add this code at the very top.

<?php /* Template Name: WPBeginnerT1 */ ?>

When you are done with that, you can change the name of your template, its styling and make any other changes to your page. Then you need to go to your WP admin panel and there you create a new page and select “Default Template”. Once you have published this page, you need to go to settings>Reading and from here you select your custom page as the Home page.

2)      Create a Page that Displays Random Posts

Now this cool feature is very much in demand. Often you see while visiting a website a link on the top navigation panel of the website that allows you to read creative articles and texts and when you click on that link, it takes you to that random page and each time you refresh the page you will see a fresh new content available for the reading. Here we show you how to get it.

First, you will need to create a custom page like we mentioned above in trick number one and then simply paste this code in that page.

01 <?php

02 query_posts(array(‘orderby’ => ‘rand’, ‘showposts’ => 1));

03 if (have_posts()) :

04 while (have_posts()) : the_post(); ?>

05

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

07

08 <?php the_content(); ?>

09

10 <?php endwhile;

11 endif; ?>

This code is a simple loop that keeps running a query to display random posts and the number 1 tells WordPress to only show one post at a time so you can change that number to your liking.

3)      Highlight Author’s Comments

On many WordPress sites, we see the Author’s comments look different from the others. For this, you need to open your style.css in the template folder and make the following changes.

1 .authorstyle { background-color: #B3FFCC !important; }

After that, you need to open your comments.php, which is located in the themes folder, and look for the code that looks like this.

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

You need to replace that with this,

1 <liauthorstyle”; echo $oddcomment; ?>”></li>

Don’t forget to change the user id 1 to the author’s user id. Once you are done doing that, your author comments will have a different background from the rest.

We hope that these tricks will improve your WordPress development skills and give you an edge over other WordPress developers. You can always contact us for your WordPress related queries and problems and we will be more than happy to accommodate you.

Share If You Like It
  • Usman Tariq

    That’s nice.

  • http://anuragaggarwalinstituteofpublicspeaking.wordpress.com/ Anurag Aggarwal

    Good one. Quite helpful.