Connect with us

Communities

9 Useful WordPress Hook Hacks

Published

on

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:

functiondisableAutoSave(){

wp_deregister_script(‘autosave’);

}

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

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

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: mubeenh782@gmail.com  

Continue Reading
Click to comment

You must be logged in to post a comment Login

Leave a Reply

Communities

Get The Best Results By Choosing The Expert Debt Service Provider Offering Ideal Solutions

Published

on

The life isn’t always easy. It is possible to encounter unanticipated financial problems that can lead to financial problems. The stress of dealing with these issues could make you feel anxious. However, solving a debt issue may not be to be as simple as it seems. It’s a complicated procedure, which can make your life more difficult. It can be difficult to handle such circumstances and requires experts to guide you. It can be difficult to make a decision when you need to make decisions in the area of finances.

It is important to have the assistance of a professional to tackle the difficult job. Expert assistance from professionals will help you make the right choice to get your finances back on the right track. It is essential to seek the appropriate help to simplify and resolve the issues. For the best source of help that can provide effective solutions to reduce debt and teach strategies for managing money it is essential to conduct some investigation. When choosing the right business to receive financial debt relief could be a daunting task but you must take a look at the following characteristics prior to making a decision.

Accreditation Of The Company

It is important to confirm the credentials and accreditation of the company you pick. An authentic company has many years of experience in service to customers and is rated highly from customers. Visit the website to verify that the business is located at physical addresses and contact information. When verifying, be attentive to complaints of previous customers. If you are dealing with companies that have non-profit status You must request the proof that they are charitable. Beware of companies who fail to disclose this information.

Analyze The Structure Of The Plan

Before deciding to accept the help before deciding to accept the assistance, you must obtain all the relevant information from the firm in writing. You should read up on the plant, the price and the various methods that are suggested click for more info. Examine if the strategy suggested corresponds to your present situation. Check to see whether the plan suggested is a good match.

Low-Interest Loans

The organization offering assistance must offer loans with low rates to pay off debts. The loans for debt consolidation must be in line with your budget and eliminate your existing debts. Examine your budget thoroughly to figure out the cheapest monthly installment to settle the debts. Also, be cautious when selecting the duration for the loan. You should only consider it if it is within your budget. A cost-effective and feasible alternative will help you get out of credit card.

Offer Accurate Information

A trusted and responsible service provider should provide all details, including the cost of providing the solution. Access to all documents so that you are able to read these terms of service in detail before making a final decision. The service provider must explain the agreement in simple terms. They should also be able to answer your queries and concerns.

Transparency

The service provider should provide all the information needed to make the right choice. That means you will need information on the pros and cons when you are considering debt service. This information is transparent and can help you understand how these plans may affect your financial interest and also how you can safeguard the interest of your clients.

Although you might want to get the most serious solutions to your debt by contacting the experts immediately but you must remain patient while selecting the provider. Although your issue requires immediate care, it is only through a thorough study can lead you to choose a firm that can provide the best solution to help you get out of the mess.

It is best to choose a reputable company that has experts to guide you and offer the best ways to tackle financial issues. It is possible to make the process more simple with them.

Continue Reading

Trending