5 Usefull WordPress Hacks

The following article will introduce something that we consider to be highly important and useful – we’re talking about WordPress hacks. The internet these days is truly over-flowing with offers and advice on WordPress hacks issue, as everyone wants to customize their WordPress presence to make their blog the one that really stands out. Nothing wrong with that of course, but all too often the hacks you find on the net can be purely confusing for anyone who isn’t already an expert WordPress user or a programmer. So, we hope that these WordPress hacks will be particularly useful to WordPress newbies who are searching for useful, quick, and easy-to-use WordPress hacks.

WordPress hacks for social networks

You shouldn’t underestimate the value of social networks as they can give a maximum exposure to your blogs. With two biggest social networks continuing to be Facebook and Twitter it would be careless indeed not to include WordPress hacks that you can use for them. Whilst your blog subscribers can automatically receive an alert to a new posting – why not to add an automatic “blog share on Facebook” link, so that your blog posting could be automatically available to your Facebook followers and shared by them as well. Within the loop simply add this code to your single.php file:

[Sharing blogs on Facebook code:]

<a href=”http://www.facebook.com/sharer.php ?u=<?phpthe_permalink();?>&t=<?php the_title(); ?>” target =”blank”> share on Facebook</a>

Presuming you’re loving Twitter as much as Facebook, then no doubt you’ll be keen to know how to get all your Twitter followers to retweet your blog post further. OK, so there’s a WordPress plugin to send new blog posts to Twitter, but what about old postings? To get your Twitter friends retweeting even your old blog entries add the following code, above or below the posting loop and outside the ‘div’ containing “the_content”.

[Code for Tweeting old blog postings:]

<a href=”http://twitter.com/home?status=RT @HackWordPress<?phpthe_title ();?><?php echoget_settings(‘home’); ?>/?p=<? phpthe_ID(); ?>”>Tweet This</a>

WordPress hacks for protection

Anyone who is just starting using WordPress will be impressed of how easy it is to work with this platform. But later on they will apparently have some nagging worries about how secure it is to run their blog and have the data stored. So here are a couple of WordPress hacks to help you make sure that your WordPress security is of highest level to protect all that data you’ve created and collected. However, there’s one WordPress file that you definitely don’t want anyone else to get inside of – that’s your “wp-config.php” file. This is where the string to connect with your database is stored and it needs protection. Find your .htaccess file and add the following code in lines as shown:

[wp-config.php file protection:]

<fileswp-config.php> orderallow,deny deny from all </files>

If you’re still worried about someone hacking into your database and you have a static IP address – then why not restrict your WordPress administration access to only your specific IP address. To achieve this again edit your .htaccess as follows, but using your own static IP address of course:

[Restricting admin access:]

order deny, allow allow from 111.222.333.44 deny from all

Removing unnecessary links

Some bloggers still believe that the more links they have on a page the better it will be in search engine rankings. Of course, links are very important, yet unnecessary links can actually work against you in terms of search engine optimization. To remove unnecessary links you need to edit your wp-includes/post-template.php file:

[Original links information:]

$output .= ‘ <a href=”’ . get_permalink() . “#more-$id\”>$more_link_text</a>”;

[Removing unnecessary links code:]

$output .= ‘ <a href=”’ . get_permalink() . “\”>$more_link_text</a>”;

Distinctive new post WordPress hack

Ever wondered if you can make a new blog post look more distinctive than the older ones? Well if you actually have, here’s an easy to invoke WordPress hack that can present a blog, posted within the previous 24 hours, in a special style sheet. Find the loop in your index.php file and make the following edits:

[Code for Tweeting old blog postings:]

<?php if (have_posts()) : ?> <?php while (have_posts()) : the_post(); $currentdate = date(‘Y-m-d’ ,mktime(0,0,0,date(‘m’),date(’d’), date(’Y’))); $postdate = get_the_time(‘Y-m-d’); if ($postdate==$currentdate) { Echo ‘<div class=”post new”>’; } else { echo ‘<div class=”post”>’; } ?> <a href =”<?phpthe_pirmalink() ?>rel=”bookmark”> <?phpthe_title(); ?></a> <?phpthe_time(‘j F Y’); ?> </div> <?phpendwhile; ?> <?phpendif; ?>

[Removing unnecessary links code:]

.post{ /* CSS style for “normal” posts */ } .post.new { /* CSS style for newer posts *

Two “Comments” WordPress hacks

It’s all well and good seeing how many comments have been left on any of your blog postings, but what about the total number of comments being left on your blog since the time it has been launched? Remember that the number of comments left on your blog will often be used by new visitors to make judgements as to the efficacy of your blog. So the bigger number of visitors’ comments you can present the better. This simple WordPress hack will let you place, anywhere you like in your blog, the total number of comments left on all your blog postings:

[Stylesheet alteration for distinctive blogs:]

<?php $numcomms = $wpdb->get_var(“SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = ‘1’”); if (0 < $numcomms) $numcomms = number_format($numcomms); echo “There’s “.$numcomms.” total comments on my blog”; ?>

Finally, when someone leaves a comment in your blog, WordPress automatically displays an “Edit” link next to it. However, if you want to delete it or declare the comment as spam, most probably you’ll have to log in to the admin panel. Wouldn’t it be useful to be able to delete comments or tag them as spam in the blog itself? Well, by tweaking the code that contains the “Edit” comments link you can do it. In the theme that you’re using paste the following part into your function.php file:

[delete/spam tag by blog comments:]

functionspam_delete_comment_link($id) { global $comment, $post; if ( $post->post_type == ‘page’ ) { if ( !current_user_can( ‘edit_page’ , $post->ID )) return; } else { if ( !current_user_can( ‘edit_post’ , $post->ID )) return; } $id = $comment->comment_ID; if ( null === $link ); $link = __(‘Edit’); $link = ‘<a class=”comment-edit-link” href=”’ . get_edit_comment_link ( $comment->comment_ID ) . ‘”title=”’ . __( ‘Edit comment’ ) .’”>’ .$link . ‘</a>; $link = $link .‘ |<a href=”’ .admin_url(“comment.php?action=cdc&c=$id”).’”> del</a> ‘; $link = $link . ‘ |<a href= “ ‘ .admin_url(“comment.php?action=cdc&dt=spam&c=$id”).’”> spam</a>’; $link = $before . $link .$after; return $link; } add_filter(‘edit_comment_link’, ‘spam_delete_comment_link’);

About the Author

Thomas Cooper is a WordPress enthusiast that works as the web hosting assistant at ixwebhosting . You can reach him via his email .

09 Nov 2021

5 Joomla Real Estate Templates

Hey guys, today we are going to present you the compilation of…

Decrypting Flat Design Series 2.
21 Jun 2022

Decrypting Flat Design – A Progressive Trend or a Passing…

We have extensively discussed about the most happening web design trends i.e.…

Written by

Allison Reed

Allison is a professional SEO specialist and an inspired author. Marketing manager by day and a writer by night, she is creating many articles on business, marketing, design, and web development. Follow her on LinkedIn and Facebook.

Post Comment

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

Managed by Quantum VXenon