Best of WordPress Hacks and Tricks Developers Can Work At – Pak Coders

Best of WordPress Hacks and Tricks Developers Can Work At-pakcoders
Hacks and Tricks WordPress tutorial: while WordPress happens to be the most hotly pursued CMS platform of all, you do need to branch out of the defaults to make your WordPress website gain singularity. The job becomes a tad easier, simply for the fact that we know how customizable the WordPress is. Extending WordPress beyond defaults thus seems like a feasible endeavor.
Now, there are gazillion of themes and plugins making their way to the WordPress realm by the hour, and consequentially, it’s getting harder to get your website stand apart from the growing clutter.

Before the problem of plenty snowballs into serious issues for you, let’s take a look at some extremely WordPress hacks that let you strengthen your website and also perform multitude of features and fixes in no time.

1. Display Latest Post in Sidebar

This is one of those elementary, yet very decisive WordPress hacks that should be accomplished without putting in too much efforts. The feature is useful if it is applied on a theme. The process is quite simple to do. All you need just open the sidebar.php file and add the below mentioned code to display the latest post in the sidebar area.

<?php wp_get_archives('type=postbypost&limit=5'); ?>


2. Use Flawless JPG Images

Displaying high-quality images enhances the overall visual appeal and character of your website. It’s a good practice to breed confidence and trust among your visitors, not to mention the space and bandwidth the truncated files (without affecting the quality) save. To ensure your images are of supreme quality, insert the following code to your theme’s function.php file.

add_filter( 'jpg_quality', 'high_jpg_quality' );
function high_jpg_quality() {
return 100;


3. Accurate URLs

Having a proper URL structure is extremely important to prevent your visitors getting riled up whenever they encounter 404 error. An accurate URL structure is also crucial in terms of SEO ranking of a website. To ensure your URLs are free from invalid characters, you can add this function in esc_url() function:

$my_url = '';
$url = esc_url( $mywebsite_url );


4. Make Use of General Taxonomy Functions

WordPress comes packed with a great deal of taxonomy functions that let you manage and handle a variety of taxonomy functions including built-in tags and categories. The codex provides a handy list of all these functions that help you make things like categories, posts, bookmark functions, taxonomy functions much more streamlined.

5. Create Sessions Within WordPress

Setting up of sessions is a useful practice of storing information between pages and it has been widely followed by a number of websites. WordPress doesn’t allow this function to be used internally. However, you can set up a session of your own using the following code. But before you actually start the process, be ensure about checking IP addresses and adding some protection just to be on a safer side.

add_action( 'init', 'example website session_start' );
function example_session_start() {
if ( !session_id() ) {


6. Fixing the Issues When a Post Goes RSS

There are times when you suddenly observe that there are some mistakes in your post after finally publishing it. It’s quite easy to fix such errors, but it’s already too late for your subscribers- as your post has gone live and has got published their RSS feeds.

There is no need to worry about. You can still fix such errors and edit your live post. All you need is simply add the following code in your functions.php file.

function publish_later_on_feed($where) {
global $wpdb;
if ( is_feed() ) {
$time_now = gmdate('Y-m-d H:i:s');
$time_delay = '15'; // integer
$where = " AND TIMESTAMPDIFF($device, $wpdb->posts.post_date_gmt, '$time_now') > $time_delay ";
return $where;
add_filter('posts_where', 'publish_later_on_feed');



7. Making Changes in the Default Gravatar

This hack is really awesome if you seriously want to revamp the overall appearance of your theme. You can go about it by adding the following code in your functions.php file.

if ( !function_exists('linkedin_addgravatar') ) {
function linkedin_addgravatar( $avatar_defaults ) {
$myavatar = get_bloginfo('template_directory').'/gravatar.gif';
//default avatar
$avatar_defaults[$mynew avatar] = 'My new gravtar';

return $avatar_defaults;

add_filter( 'avatar_defaults', 'linkedin_addgravatar' );



8. Customizing the Dashboard Logo

WordPress users can opt to add their own logo in the dashboard to give a more personal touch to the installation process. This is a pretty useful hack and looks great on client websites. Just use the following code:

add_action('admin_head', 'custom_logo');
function custom_logo() {
echo '<style type="text/css"><!-- #header-logo { background-image: url('.get_bloginfo('template_directory').'/images/custom-logo.gif) !important; } --></style>';



9. Getting Rid of The Error Message on the Login Page

Whenever the user enters your website and provides a username or password that is wrong, an error message is displayed on the login page, asking user to provide the correct information. If a hacker guesses the information correctly, chances of getting your site hacked increases. To block hackers access the information of your website insert the following filter. Please note- Site with multiple authors can’t perform this hack.

add_filter('login_errors',create_function('$a', "return null;"));




Add a Comment

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