
WordPressis improved with some perhaps essential functions that are either extensively misinterpreted or totally neglected by programmers that’re taken part in managing numerous WordPress growth jobs. Whether it’s regarding sub-par WordPress advancement or expert WordPress advancement, an in-depth knowledge regarding the tailored management filtersis something that will certainly aid you in executing your tasks with a wider expectation.
add_ping
This WordPress filter hook is being applied to every new value of the pinged field that’s available on a particular blog post under a situation where the ping is added before saving the new details into the database.
A bespoke filter for photographers
If you’re a photographer who’s showcasing his/her work via a WordPress website then you can simply paste the below mentioned code into the functions.php file for eliminating any changes for automatic compression of images:
1
|
add_filter('jpeg_quality', function($arg){return 200;}); |
Doing this not only saves you an incredible amount of bandwidth and loading time but it even allows you to have high-resolution, full-length images on your web pages.
A filter to remove the often frustrating ‘Read More’ Jump from WordPress blog posts
Almost all WordPress blog posts contain a “Read more” link which automatically redirects the user to the point within the blog where he/she read the end of. If you find these ‘Read more’ links quite frustrating then you can choose to jump from the same by pasting the below code into your functions.php file:
1
2
3
4
|
function wdc_no_more_jumping($post) { return '<a href="'.get_permalink($post->ID).'" class="read-more">'.'Continue Reading'.'</a>'; } add_filter('excerpt_more', 'wdc_no_more_jumping'); |
A handy filter for automatic replacement of words in your WordPress blog posts
If you’ve already named a blog and for some reason you choose to rename it to something else, it’s not necessary for you to edit all the blog posts in order to replace every since instance of the respective blog. Rather, you can simply choose to paste the below mentioned code in your functions.php file and the WordPress hook will do the job for you:
1
2
3
4
5
6
7
8
9
10
11
12
13
|
function replace_text_wps($text){ $replace = array( // 'WORD TO REPLACE' => 'REPLACE WORD WITH THIS' 'wordpress' => '<a href="#">wordpress</a>', 'excerpt' => '<a href="#">excerpt</a>', 'function' => '<a href="#">function</a>' ); $text = str_replace(array_keys($replace), $replace, $text); return $text; } add_filter('the_content', 'replace_text_wps'); add_filter('the_excerpt', 'replace_text_wps'); |
A filter for adding post thumbnails to RSS Feeds
With this cool WordPress filter, you can easily choose a thumbnail and automatically add it to your WordPress website’s RSS Feeds. All you need to do is simply paste the below code into your functions.php file, followed by saving the file. One crucial thing that needs to be mentioned here is that for the below code snippet to work, you’ll need to have a WordPress theme that supports post thumbnails:
1
2
3
4
5
6
7
8
9
10
11
|
function cwc_rss_post_thumbnail($content) { global $post; if(has_post_thumbnail($post->ID)) { $content = '<p>' . get_the_post_thumbnail($post->ID) . '</p>' . get_the_content(); } return $content; } add_filter('the_excerpt_rss', 'cwc_rss_post_thumbnail'); add_filter('the_content_feed', 'cwc_rss_post_thumbnail'); |
attachment_fields_to_edit
This is a filter that’s applied to form fields which need to be displayed when the user is editing an attachment. This filter is called in the get_attachment_fields_to_edit function.
A simple-to-use filter for adding target=”blank” to all links
Since target=”blank” links might not sound appealing to every WordPress developer, it’s always been pretty much interesting to find how the global clients love to include the same in their WordPress websites. So, if you too are inclined on transforming all the links within your WordPress web pages to target=”blank”, then all you need to do is simply paste the below mentioned function into your functions.php file:
1
2
3
4
5
|
function autoblank($text) { $return = str_replace('<a', '<a target="_blank"', $text); return $return; } add_filter('the_content', 'autoblank'); |
An exclusive filter for removing comment auto-links
By default, each time a user leaves a comment(containing a specific URL) on your WordPress blog, the respective URL is being automatically transformed into a link. Although this can turn to be quite useful for the site, seeing multiple links in comments can make your blog appear spammy. Therefore, you can choose to remove these auto-links by pasting the following code in your functions.php file:
1
|
remove_filter('comment_text', 'make_clickable', 5); |
Once you’re done with the code pasting process and saving the functions.php file; you’ll notice that the auto-links have disappeared from all your WordPress blog posts.
Conclusion
With a crisp and clear understanding of WordPress administrative filters, I’m sure you’d have got all geared up for applying the same to your WordPress web development projects. With actions and filters playing a critical role in empowering existing WordPress functionalities, you can definitely grab an excellent opportunity of offering your customers something new and out-of-the-box. So, its time for you to embrace these WordPress admin filters for creating that ‘ultimate’ experience for your site/blog visitors.