in

The Utmost WordPress Hooks, Hacks & Top 20 Customizations Searches of 2013

Top 20 Most Wanted WordPress Code Hacks

WordPress primarily a blogging site provides much more than you can think of. The best part is you are allowed to customize and hence arises the need for some code hacks for the people like us who are not coders but love to try and experiment to implement changes. Here is my list of 20 most wanted WordPress Code Hacks. Hope you would get some, you are looking for.

Assuming that you are looking to include new plan characteristics and usefulness to your WordPress site, chances are there is likely somebody who has recently done it and imparted the code on the most proficient method to do it. There are various extraordinary assets you can use to find remarkable hacks, customizations, and tips to make your WordPress write more one of a kind, easy to understand, and captivating.

 

Adding Social Media Aspects

Displaying Archive Posts

WordPress Hooks / Hacks Resources

Showing Author & Bio Information

Comment Features

Custom Post/Categories Features

Adding & Including RSS Features

Adding & Including Community Features

WordPress Hooks & Hacks Roundups

Top 20 WordPress Customisation searches of 2013

1. Adding Gravatars for the post author in WordPress :

Gravatar is well supported by WordPress and you can add it easily. Keep the below code snippet in the loop;

Note: get_the_author_email () outputs the post author’s email whereas the the size of the avatar image in pixels is kept 80.

 

2. Automatic creation of Users In WordPress :

There is a function wp_insert_user() used for the automated creation of users. Open functions.php and use the code given below;

function fb_wp_insert_user() {
	$user_data = array(
		'ID' => '',
		'user_pass' => wp_generate_password(),
		'user_login' => 'dummy',
		'user_nicename' => 'Dummy',
		'user_url' => '',
		'user_email' => 'dummy@example.com',
		'display_name' => 'Dummy',
		'nickname' => 'dummy',
		'first_name' => 'Dummy',
		'user_registered' => '2010-05-15 05:55:55',
		'role' => get_option('default_role') // Use default role or another role, e.g. 'editor'
	);

	$user_id = wp_insert_user( $user_data );
}
add_action( 'admin_init', 'fb_wp_insert_user' );

 

3. Display relative dates in WordPress :

Download activate the plugin wp-relativedate and then in files single.php, index.php, and page.php change code A to code B.

Code A 

Code B

 

4. Link to External Links from Your Post Title :

First open your functions.php file and add the following codes in there (in php tags)

function print_post_title() {
global $post;
$thePostID = $post->ID;
$post_id = get_post($thePostID);
$title = $post_id->post_title;
$perm = get_permalink($post_id);
$post_keys = array(); $post_val = array();
$post_keys = get_post_custom_keys($thePostID);
if (!empty($post_keys)) {
foreach ($post_keys as $pkey) {
if ($pkey=='url1' || $pkey=='title_url' || $pkey=='url_title') {
$post_val = get_post_custom_values($pkey);
}
}
if (empty($post_val)) {
$link = $perm;
} else {
$link = $post_val[0];
}
} else {
$link = $perm;
}
echo '
'.$title.'
';
}

Then open the index.php and replace code A by code B,

Code A
<a href="" rel="bookmark">
Code B

 

5. Highlight Author’s Comment :

Open your style.css in your template folder and add the following code,

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

Then open the comments.php (in themes folder) and replace Code A with Code B,

Code A
<li id="comment-">
Code B
<liauthorstyle"; echo $oddcomment; ?>">

Note: All you need is to change the user_id value and you are done.

 

6. Display Twitter Follower Count as Text :

Create twitter.php and then paste the following code in there:

<?php
$tw = get_option("twitterfollowerscount");
if ($tw['lastcheck'] (.*)

Replace wpbeginner with your twitter name. Then simply place this code anywhere you want to display this:


 

7. Control When Your Posts are Available via RSS :

Add following code in functions.php:

function publish_later_on_feed($where) {
global $wpdb;
if ( is_feed() ) {
// timestamp in WP-format
$now = gmdate('Y-m-d H:i:s');

// value for wait; device
$wait = '10'; // integer

// http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_timestampdiff
$device = 'MINUTE'; //MINUTE, HOUR, DAY, WEEK, MONTH, YEAR

// add SQL-sytax to default $where
$where .= " AND TIMESTAMPDIFF($device, $wpdb->posts.post_date_gmt, '$now') > $wait ";
}
return $where;
}
	add_filter('posts_where', 'publish_later_on_feed');

Note: You can change the time from 10 minutes to whatever you like.

 

8. Display Random Header Images in WordPress :

First you need to name your images in sequential format and separate the name with an underscore. Then paste the following code in your header.php

<img src="http://path_to_images/headerimage_.gif"
width="image_width" height="image_height" alt="image_alt_text" />

Note that ‘X’ is number of images you want to display.

 

9. Display selective categories in a menu :

If you use the default wp_list_categories code, it will show all categories. Use below code for selective categories:

 also change the ‘include’ text to ‘exclude’ and show all categories and exclude those that you don’t want displayed. You will also need to edit the CSS in order to make it work.

 

10. Set expiry dates for your posts

All you need to do is replace your WordPress Loop with this code:

$expirationtime = get_post_custom_values('expiration');
if (is_array($expirationtime)) {
$expirestring = implode($expirationtime);
}

$secondsbetween = strtotime($expirestring)-time();
if ( $secondsbetween > 0 ) {
// For example…
the_title();
the_excerpt();
}
endwhile;
endif;
?>

Note: Select the key “expiration” and use the date format: mm/dd/yyyy 00:00:00

 

11. Deleting post revisions from your database :

Login to your phpMyAdmin and then select your WordPress Database. Press the SQL Button and enter the following query:

DELETE FROM wp_posts WHERE post_type = "revision";

 

12. Custom CSS StyleSheet For Individual Posts :

Insert the following between tags in header.php:

ID, 'customstyle', true);
if (!empty($customstyle)) { ?>

Note: Then custom fields with name and custom style are added using CSS. Let us take an example : In order to add border to certain image then add following code:

#coolimageclass{border: 5px solid #ccc;}

 

13. Display Latest Sticky Posts in WordPress :

For this one pre requisite is to create a custom page template and/or have the Loop ready. Then paste the following code before the loop.

 $sticky, 'caller_get_posts' => 1 ) );
?>

 

14. Display a Retweet Button On Your Site :

Add the following code in the template file of your choosing most likely single.php

For large button:

tweetmeme_source = 'wpbeginner';

For compact button:

tweetmeme_style = "compact";
tweetmeme_source = 'wpbeginner';

Note: Here the source should be changed to your twitter account name.

 

15. Add Custom Header, Footer, or Sidebar on Different Categories :

Open index.php and replace the normal header code with the following:

Add following code to get a separate sidebar for each:

Add following code to get a separate footer for each category:

 

16. Disable HTML in WordPress Comment :

All you have to do is simply open your functions.php and add the following code:

// This will occur when the comment is posted
function plc_comment_post( $incoming_comment ) {
// convert everything in a comment to display literally
$incoming_comment['comment_content'] = htmlspecialchars($incoming_comment['comment_content']);
// the one exception is single quotes, which cannot be #039; because WordPress marks it as spam
$incoming_comment['comment_content'] = str_replace( "'", ''', $incoming_comment['comment_content'] );
return( $incoming_comment );
}
// This will occur before a comment is displayed
function plc_comment_display( $comment_to_display ) {
// Put the single quotes back in
$comment_to_display = str_replace( ''', "'", $comment_to_display );
return $comment_to_display;

 

17. Display categories in dropdown menu :

Add following code to get the desired effect:

<form action="/" method="get">
<?php
$select = wp_dropdown_categories('show_option_none=Select Category&show_count=1&orderby=name&echo=0&selected=6');
$select = preg_replace("#]*)>#", "", $select);
echo $select;
?>

 

18. Displaying the most recent post as per category :

Add the following code to template and don’t forget to change the category ID.

<a href="" rel="bookmark">

Note: You can also manage the number of posts you want to display.

 

19. Author’s Twitter and Facebook Information on their Profile Page :

Open functions.php and paste the following code:

 The above code will add two extra fields on your user-edit page named twitter and Facebook. You can display the code with the following code in your author.php file.
twitter; ?>

 

20. Display Guest Author’s Name via Custom Field :

Open single.php or page.php in your template and add the following code where you display the author name:

ID, "guest-author", true);
if ($author != "") {
echo $author;
} else {
the_author();
} ?>

Note: You might have to remove the original the_author function before you place this.

Throughout the year 2013 I have gathered various incredible assets over the web that I thought might be an extraordinary thought to arrange and allotment. I might sway every living soul to leave their top choice WordPress Hack in the remarks underneath.

Well I know this is pure code but this is what this post was all about. I hope you would try some or may be all and get what you wanted. Enjoy!

Written by Amit Tripathi

Being an professional blogger, Amit has work on many professional blogs for same niche. Get Amit on Google+

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

Loading…

qr code contact customer

Building the Bridge: Staying Connected with Your Customers by Using Free QR Codes

Most Creative Info-Graphic Designs For Inspiration