Connect with us


9 Useful WordPress Hook Hacks



WordPress has established itself as a potential CMS (Content Mangemnet System) over the years. Many of the globally popular websites like Sony Music, BBC America, TechCrunchetc are running on the CMS. The extenet of its effectiveness and popularity can be understood from the fact that around 40% of the websites that are active today are running of the CMS. The open source and free avialabiity adds further to its popularity.

Many firms nowadays don’t look to develop their CMS. Rather they think why not look here to top full stack WordPress developer to get things done. WordPress developers are kept busy thanks to the demand and popularity of the platform. However, you not always have to look for a developer to make your website attractive using the WordPress. Yes, you can do manythings on your own as well.

What Are Hook Hacks?

What we are talking here are hook hacks. Hook is basically a method to make changes in the working of WordPress through changes in it’s core files. Since the changes in the core files are involved there are chance of creation of security loopholes thus, the hooks are less recommended. However, you can bring such changes through hook hacks. Wondering how, well that’s what the main thing that we are going to discuss it out here.

Auto Formatting 

Auto formatting is by default available in the WordPress. It makes certain formatting changes to the content when the post gets displayed. If you want to display some specific kind of content say  program code then it can be annoying.

To remove this issue all you need is copying the below given code in functions.php file:

functionmy_formatter($content) {

  $new_content = ’;

  $pattern_full = ‘{([raw].*?[/raw])}is’;

  $pattern_contents = ‘{[raw](.*?)[/raw]}is’;

  $pieces = preg_split($pattern_full, $content, -1, PREG_SPLIT_DELIM_CAPTURE);


  foreach ($pieces as $piece) {

    if (preg_match($pattern_contents, $piece, $matches)) {

      $new_content .= $matches[1];

    } else {

      $new_content .=ptexturize(wpautop($piece));



  return $new_content;


remove_filter(‘the_content’, ‘wpautop’);

remove_filter(‘the_content’, ‘wptexturize’);

add_filter(‘the_content’, ‘my_formatter’, 99);

Google Analytics 

Installing Google Anlaytics is important for the SEO and web traffic assessment on your website. The effective way to do is through the third party plug-in. This would help you in avoiding coding hassles as they are based on customized needs of different kinds of websites.

Controlling Login  

By default the WordPress allows you unlimited login attempts to the website. This can be kind of exposes the website to encroachment of cyber attacks. To limit these attempts you need a plug in called the Login LockDown to set the limit.

Comment Notification 

Comments of visitors on websites is a good thing not only for SEO but for the creditibility of your website as a source as well. To better connect this feature with users you should provide them notification when some new comment is received on their comment. This is commonly done through e-mail notifications. You have to install the Subscribe to Comments plugin and activate it in the settings to get the feature rolling.

Categories To Pages 

The default mechanism of the CMS allows adding tags and categories to each specific post and not the webpages. The reason is that web pages are considered as static content.

However, you can add categories to the pages as well. Just go to the site-specific plugin or file named functions.phpan copy this code:


// add tag and category support to pages

functiontags_categories_support_all() {

  register_taxonomy_for_object_type(‘post_tag’, ‘page’);

  register_taxonomy_for_object_type(‘category’, ‘page’);  



// ensure all tags and categories are included in queries

functiontags_categories_support_query($wp_query) {

  if ($wp_query->get(‘tag’)) $wp_query->set(‘post_type’, ‘any’);

  if ($wp_query->get(‘category_name’)) $wp_query->set(‘post_type’, ‘any’);



// tag and category hooks

add_action(‘init’, ‘tags_categories_support_all’);

add_action(‘pre_get_posts’, ‘tags_categories_support_query’);


Breaking of Code Snippet 

The WordPress software converts the quotes entered as normal text into smart codes. Due to this this their develops a risk of breaking the code snippet that is required to be published. You can avoid this by copying another snippet in the  functions.php file. The snippet that we are talking about is:

remove_filter (‘the_content’, ‘wptexturize’)

Enhancing Memory

Have you seen memory exhausted error when you install a big plug in file? If yes then do you know you can enhance the memory in WordPress? Yes, it is possible to do by copying the code:


define(‘WP_MEMORY_LIMIT’, ‘64M’);

In the wp-config.php file.


Stop Auto Saving 

WordPress has a system of storing posts automatically after a specific period of time. Though this is a useful thing sometimes you want to avoid that. Well, its easy to do that. To disable auto saving go to functions.phpand copy this code:




add_action( ‘wp_print_scripts’, ‘disableAutoSave’ );


Delay RSS Feeds

It happens quite often that we publish a post that is meant to be posted sometime later. Though we can delete the post and reschdule the RSS feed readers and your e-mail surbvcirbers would get that post in their box. This can disturb your website’s reputation and thus is a serious issue. Don’t worry as you can delay the going of a post to the feeds after its publishing by as much as 10 minutes.

Just go to the functions.php file of the theme and copy the code:


global $wpdb;

if ( is_feed() ) {

// timestamp in WP-format

$now = gmdate(‘Y-m-d H:i:s’);


// value for wait; + device

$wait = ’10’; // integer




// 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’);

Hi. I am Muhammad Mubeen Hassan. I am SEO Expat and Wordpress Websites Developer &  Blogger. 30 years old. I help entrepreneurs become go-to in their industry. And, I like helping the next one in line. You can follow my journey on my blog, for list Click Here If you need any post so you can email me on my this Email:  

Continue Reading
Click to comment

You must be logged in to post a comment Login

Leave a Reply


How much is the fee for spouse sponsorship?



Spouse sponsorship is also referred to as a Spouse visa or UK marriage visa. This visa allows you to enter the UK as a foreign nation and live and work there. You may apply for this visa as a partner, wife, husband, or fiancé if your partner is a British citizen. This visa allows you to live in the UK for up to 2.5 years. You can extend your stay to a further 2.5 years. This visa could become your first step towards long residency and later British citizenship.

Prerequisites to apply for spouse visa

  1. You must be 18 years or above.
  2. Either of the partner/spouses is a British citizen or has UK settled status.
  3. The partner/spouse is already living and working in the UK before 01 January 2021 if they are from Switzerland, Norway, Iceland, Liechtenstein, or EU nationals.
  4. They have refugee status in the UK.
  5. The individuals are already married and living together or are in a civil partnership for at least 2 years. When you apply, the partners must enter into the civil partnership within 6 months of coming to the UK.
  6. The partners should sustain themselves in the UK financially without seeking public funds.
  7. The partners must also meet minimum financial requirements to stay in the UK.
  8. The annual income should be at least £18,600.

The cost of spouse sponsorship

  1. If the partner/spouse are applying from within the UK, then they are asked to pay £1033
  2. The visa seeker also needs to pay £19.20 for biometrics.
  3. If the partners are applying from outside the UK, the fee is slightly higher. They must pay £1523.
  4. When your visa is granted outside the UK for 33 months, the total surcharge would be £1,872.
  5. The total surcharge for a spouse visa for 2.5 years would be £1560 for leave to remain.
  6. Besides, an Immigration Health Surcharge, which is £624 per year, has to be paid. It is charged as £312 for every 6 months.

Application process involved

The application process is online. You may need to enrol at a visa appointment centre for your biometrics, including photographs and fingerprints.

Besides, there are additional documents required for you to upload in the application process.

The second step could be time-consuming. You can take the support of a UK immigration lawyer who has expertise in spouse visa applications and can handle your case with care and compassion.

Checklist of supporting documents

Officials at UK Visas and Immigration (UKVI) may ask you to submit the following documents

  1. Bank statements
  2. Employment income documents, if applicable
  3. Marriage or civil partnership certificate.
  4. Details of any children accompanying to the UK
  5. Current passport or other travel documents.
  6. Your sponsor’s British passport or Indefinite Leave to remain document.
  7. Divorce certificate for any previous marriages, if applicable.
  8. Details of your stay in the UK.
  9. Your National Insurance number
  10. Details of any criminal record, if applicable.

Other mandatory requirements

Visa seekers must fulfil the English proficiency requirements in both speaking and listening. At first, you are required to pass the CEFR level A1 test for speaking ad listening.

While initiating extension after 2.5 years, you must pass the CEFR level A2 test, which is one step difficult than beginner A1 level.

If you intend to apply for settlement, you must pass CEFR level B2 proficiency in the English language.

Continue Reading