20+ Codes and Hacks Every Wordpress User Should Know

ADVERTISEMENTS

I’ll call this article an evergreen article because today I am going to tell you top 22 tips, codes and hacks that every Wordpress user should know. One day or other, you will need these hacks, so here is a collection of all of them.

Famous how to’s

How to display post author name ?
How to make post author name hyperlinked to its website ?
How to display categories below/after each post ?
How to display tags below/after each post ?
How to display Gravatar of the post author ?
How to display previous and next post after each post ?
How to display the number of article author has written ?
How to display breadcrumb above post title for better SEO ?
How to display archives after each post ?
How to display Blogroll links ?
How to display tag cloud ?
How to Display Edit Buttons To Your Theme ?
How to Display a Print Button To Your Theme ?
How to change default username in Wordpress ?
How to display page menu ?

Security Related

How to backup Wordpress posts and comments ?
How to backup Wordpress Database ?
How to delete all trackbacks ?
How to Create .htaccess File For Wordpress blog ?
How to change your Wordpress theme : Correct Method ?

Posts and comments Related

How to display recent posts ?
How to display recent comments ?

How to display post author name ?

Simply copy the code below and paste it in your Wordpress theme where ever you want to display the post author name.

<?php the_author() ?>

How to make post author name hyperlinked to its website ?

If your Wordpress does not show author name then simply copy the code below and paste it in your Wordpress theme wherever you want to display the post author name. The author name will be a hyperlink linking to author archive.

<?php the_author_link(); ?>

How to display categories below/after each post ?

To show categories, paste the code below where ever you want categories of the post to appear.

<?php the_category(‘, ‘) ?>

How to display tags below/after each post ?

To display tags, paste the code below where you want tags of the post to appear.

<?php the_tags(); ?>

How to display the number of articles, author has written ?

You can use the following code to display number of articles author has written.

<?php the_author_posts(); ?>

How to display breadcrumb above post title for better SEO ?

To show breadcrumbs, install a famous plugin called Yoast Breadcrumbs, after activating this plugin, paste the following code, where you want to show breadcrumb.

<?php if ( function_exists(‘yoast_breadcrumb’) ) {
yoast_breadcrumb(‘<p id=”breadcrumbs”>’,'</p>’);
} ?>

The best position will be above the post title.

How to display archives after each post ?

To display, archives, copy the code below and paste it where ever you want to show the archives.

<?php wp_get_archives(‘type=monthly’); ?>

How to display Blogroll links ?

Copy and paste the code below, to display Blogroll links

<?php get_links_list(); ?>

How to display tag cloud ?

Tags cloud is a good way to give your readers a wide range to search your blog. To display it, you can use the following code

<?php wp_tag_cloud(’smallest=7&largest=35&’); ?>

How to Display Edit Button To Your Theme ?

Edit buttons are used to  quickly edit any post while you are viewing your own blog as admin. To add it to your post, paste this code in single.php file.

<?php edit_post_link(__(“**Edit**”), ”); ?>

How to Display a Print Button To Your Theme ?

For it, we will use the following HTML code.

<a href=”javascript:window.print()” rel=”nofollow”>Print this article</a>

Use it and enjoy!

How to display page menu ?

To show the pages menu, you can use the following code.

<?php wp_list_pages(‘title_li=’); ?>

How to backup Wordpress posts and comments ?

Taking backup of posts and comments is very easy, log into your Wordpress dashboard and at the left under tools click on Export. A new window will open, click on Download Export file and save the XML file. This XML file will contain your posts, pages, comments, custom fields, categories, and tags.

How to backup Wordpress Database ?

Taking database backup on Wordpress is very easy, you can use a plugin named WP-DB-Backup. Install it and activate it, and you can easily backup Wordpress database. Click here for detailed information on how to use this plugin.

How to delete all trackbacks ?

To delete all trackbacks, log into Wordpress dashboard, and in the left hand side click on Comments. On the top right corner in the search box type [...] and hit Enter. Have a look :


This will open the list of all trackbacks and now you can easily delete all the trackbacks.

How to Create .htaccess File For Wordpress blog ?

.htaccess (Hypertext Access) is a web server configuration file responsible for the performance of your website. Below is a simple way to create a .htaccess file if your root folder does not have it.

Open any text editor say Notepad and save the empty document as .htaccess. Please note that the file should not be .htaccess.txt, if it is there then remove the extension and upload it to the root folder using any FTP program.

How to display recent posts ?

There is a default option given by Wordpress with which we can automatically add recent posts in the sidebar. What if we want to display recent posts in the template ? Here is a simple code for it.

<?php query_posts(’showposts=10′); ?>
<ul>
<?php while (have_posts()) : the_post(); ?>
<li><a href=”<?php the_permalink() ?>”><?php the_title(); ?></a></li>
<?php endwhile;?>
</ul>

This code will display recent 10 posts.

How to display recent comments ?

To show recent comments anywhere in your template, use this plugin called Get Recent Comments.

I hope you like this collection, now I am waiting for your comments and replies.


If you like this post, you will love these :

  1. How to Create Author.php Page For Your Wordpress Blog
  2. How To Change The Wordpress Default User Name
  3. How To Add Gravatar Beside Each Post In Wordpress
  4. 10 Most Important Plugins And Widgets For Your New Wordpress Blog
  5. Best Method To Change The Theme Of Your Wordpress Blog
  6. How To Display Author’s Profile/Bio In Wordpress Blog
  7. How To Change/Modify AutoSave Interval Time In Wordpress

Gaganpreet Singh on January 26, 2010 | Filed Under Wordpress

{ 1 trackback }

Serious Monday Roundup #26
February 3, 2010 at 11:32 am

{ 5 comments… read them below or add one }

1 Nasif January 27, 2010 at 10:15 am

Excellent basic tips for wordpress user…

Reply

2 George Serradinho January 27, 2010 at 11:55 am

Some nice tips you listed, sure makes some of our lives easier. Will list this post on next weeks Monday roundup, sure others will enjoy it.

Reply

3 Gaganpreet Singh January 27, 2010 at 1:42 pm

yea, Thanks George…

Reply

4 BingMyMovies.Co.Nr February 3, 2010 at 4:25 pm

Thanks for sharing the hacks. They are useful and handy for every blogger

Reply

5 sunder February 14, 2010 at 3:01 am

nice hacks but one should know how to use them

Reply

Leave a Comment

Previous post:

Next post: