Tag Archives: Hacks

How To Add Hacks In Your BuddyPress Site Without Loosing Them In The Next Update ?

Add actions and hacks without touching your theme’s function.php file. So that you don’t loose them anytime while running BuddyPress update.

Continue reading How To Add Hacks In Your BuddyPress Site Without Loosing Them In The Next Update ?

How To Keep Log Of WordPress PHP And Database Errors ?

Keeping Error Logs is helpful to know about invalid database queries and file requests of your website. You can easily enable error logging in WordPress either by plugin or by hack. 

Continue reading How To Keep Log Of WordPress PHP And Database Errors ?

WordPress Hack For Adding Signature After Posts Content

Open your theme’s function.php and add the following code. Remember changing text after equal sign with your own.

function custom_content_after_post($content){
if (is_single()) {
$content .= ‘<p>Load Your Content Here</p><img src=”‘. get_template_directory() .’/images/signature.png” alt=”Your Name” />’;
}
return $content;
}
add_filter( “the_content”, “custom_content_after_post” );

You may also use WordPress Signature Plugin for doing so. It allows WP users to put signatures below every post. After installing and activating it you can easily access it by navigating to WP-Admin Dashboard >> Tools >> WPSignature.

Become Google’s Verified Author For Your WordPress Blog

After getting Google’s verified authorship you will be seeing your blog post search results with the screen shot of your Google Plus Profile Image. As show below:

Google Search Results, Before And After Activating Google’s Verified Authorship

For doing this in your blog results, follow these steps

Open your theme’s header.php file and add the following given code block in head section –

<link rel=”author” href=”https://plus.google.com/107466614529996508363/posts” />

Remember:

  • Change the profile URL with your Google Plus Profile URL in the above given code block.
  • Head section is between <head> and </head> tag so add the given code in between these tags.

Now open your theme’s function.php file and the following action at last:

add_action(‘wp_head’, ‘add_google_rel_author’);
function add_google_rel_author() {
echo ‘<link rel=”author” href=”https://plus.google.com/107466614529996508363/posts” />’;
}

  • Visit your Google+ Profile.
  • Click Edit and make your +1s pubic.
  • Scroll down to  contributors section.
  • Under the heading “Contributor to” add your blog’s address.

That’s all. Next Google’s re-crawl to your blog pages will start showing your face in Google search results. So wait for it. You can  reduce this time by writing a new blog post.

Disable Comments On WordPress Media Attachments

Using WP Plugin

Download and activate Disable Comments plugin. Using this plugin admins can easily disable comments site wide or according to post type. After installation it can be accessed from settings menu of admin area dashboard.

Using WP Hack

Add this code in your theme’s function.php file:

function filter_media_comment_status( $open, $post_id ) {
$post = get_post( $post_id );
if( $post->post_type == ‘attachment’ ) {
return false;
}
return $open;
}
add_filter( ‘comments_open’, ‘filter_media_comment_status’, 10 , 2 );

How To Protect wp-config.php And .htaccess Files In WordPress ?

You can block access to your site’s wp-config file from browser by adding following code in your .htaccess file:

# Block access to wp-config
<files wp-config.php>
order allow,deny
deny from all
</files>

For blocking access to your .htaccess file add this code inside your .htaccess file:

# Block access to htaccess
<files .htaccess>
order allow,deny
deny from all
</files>

Note:.htaccess file is present in your site’s root at the same place where you find wp-config file.

WP-Hack For Adding Google+ Page Badge ‘Add to Circles’ In Your WordPress Blog

Add this code in your theme’s header.php file’s head section:

<link href=”https://plus.google.com/PageID” rel=”publisher” /><script type=”text/javascript”>
(function()
{var po = document.createElement(“script”);
po.type = “text/javascript”; po.async = true;po.src = “https://apis.google.com/js/plusone.js”;
var s = document.getElementsByTagName(“script”)[0];
s.parentNode.insertBefore(po, s);
})();</script>

Replace PageID (in bold text of above code block) with your Google+ Page ID.

Now visit your blog’s wp-admin (Dashboard) >> Appearance >>Widgets and drag text widget to your sidebar.

Paste following code inside your text widget (replacing PageID) :

<g:plus href=”https://plus.google.com/PageID” size=”badge”></g:plus>

For smaller badge use:

<g:plus href=”https://plus.google.com/PageID” size=”smallbadge”></g:plus>

Note: You can get your Google Plus Page ID by visiting your page’s profile and copying the number before /posts or /about in URL.

Function For Defining Default Post Thumbnail In WordPress

Open your theme’s function.php file and add the given function editing the thumbnail image URL (given in bold text) with your own image URL.

add_action( ‘save_post’, ‘wptuts_save_thumbnail’ );
function wptuts_save_thumbnail( $post_id ) {
$post_thumbnail = get_post_meta( $post_id, $key = ‘_thumbnail_id’, $single = true );
if ( !wp_is_post_revision( $post_id ) ) {
if ( empty( $post_thumbnail ) ) {
update_post_meta( $post_id, $meta_key = ‘_thumbnail_id’, $meta_value = ‘https://sangkrit.net/thumbnail.jpg’ );
}
}
}

How To Edit WordPress ‘Posts’ Label ?

You can edit WordPress post label to something Else. For example if you want to edit Posts (label) to Article so that anytime you or any other member visit you wp-admin (dashboard) he can see Article as a label on sidebar menu not posts (which is by default).

For doing this, open your theme’s function.php file and add the following code:

add_filter(‘gettext’, ‘change_post_to_article’);
add_filter(‘ngettext’, ‘change_post_to_article’);
function change_post_to_article($translated) {
$translated = str_ireplace(‘Post’, ‘Article’, $translated);
return $translated;
}