How to change the ‘Enter title here’ text in WordPress dynamically.

I am using the Pods Framework to developing a Content Management System (CMS) for a client. With Pods Framework plugin installed in WordPress, it’s possible to create Custom Content Types and Custom Fields. Usually this involves writing the PHP that you need by hand. With Pods, you can create all of the Custom Content Types and Custom Fields that you need from within the Pods plugin.

While developing the CMS I ran into a small issue. WordPress automatically displays ‘Enter title here’ text in the title field of any Post or Custom Content Types. When you create a new Post or Custom Content Type Pods does not correct this text to suit the Custom Content Type. Which is fine when the new Post is a Post. However lets say you are creating a CMS for a site storing customer information and the title field is being used for the Customers name then the ‘Enter title here’ is less useful and could be confusing to some.

Enter title hereI searched the internet looking for a solution to this problem. There were several approaches but where they all fell down was that they relied on a if/then statement for each Post, Page, or Custom Content Type. Which in its self is not a problem however every time you add a new Custom Content Type you have to add a new if/then statement. What I wanted was the replacement text to be created dynamically so that the function worked in all cases. So I wrote a function that will do exactly that.

Add New Customer HereThe best part is all you have to do is copy the text below and past it in to the functions.php file of your child theme and it is done. From then on the ‘Enter title here’ text will be dynamically replaced through WordPress with something like ‘Add New Customer Here’

Functions.php
function change_default_title( $title ){
     global $post;
     $enter_title_text = esc_html( get_admin_page_title() ).’ Here’;
     return $enter_title_text;
}
 
add_filter( ‘enter_title_here’, ‘change_default_title’ );

Fail2ban for the uninitiated.

What is fail2ban and why you should install it.

fail2ban_logoIn this day and age every web site owner or administrator is obsessed with improving the amount of traffic that flows to their site, even though little thought is given to weather or not, that traffic is of any use to their site or what harm it is potentially doing. Read why you need to consider who is coming to your site and what you can do to protect yourself from spammers and scammers.