{"id":1544,"date":"2015-06-20T16:50:42","date_gmt":"2015-06-20T08:50:42","guid":{"rendered":"http:\/\/binaryone.com.au\/?p=1544"},"modified":"2023-11-23T05:40:08","modified_gmt":"2023-11-23T05:40:08","slug":"how-to-change-the-enter-title-here-text-in-wordpress-dynamically","status":"publish","type":"post","link":"https:\/\/binaryone.com.au\/23\/how-to-change-the-enter-title-here-text-in-wordpress-dynamically\/","title":{"rendered":"How to change the \u2018Enter title here\u2019 text in WordPress dynamically."},"content":{"rendered":"\n<p>I am using the Pods Framework to developing a Content Management System (CMS) for a client. With <a href=\"https:\/\/wordpress.org\/plugins\/pods\/\" target=\"_blank\" rel=\"noopener nofollow\" title=\"\">Pods Framework plugin<\/a> installed in WordPress, it\u2019s 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.<\/p>\n\n\n\n<p>While developing the CMS I ran into a small issue. WordPress automatically displays \u2018Enter title here\u2019 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 \u2018Enter title here\u2019 is less useful and could be confusing to some.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><a href=\"https:\/\/192.168.0.150\/23\/wp-content\/uploads\/2015\/06\/Enter-title-here.png\"><img loading=\"lazy\" decoding=\"async\" width=\"718\" height=\"128\" src=\"https:\/\/192.168.0.150\/23\/wp-content\/uploads\/2015\/06\/Enter-title-here.png\" alt=\"Enter title here\" class=\"wp-image-1550\" srcset=\"https:\/\/binaryone.com.au\/23\/wp-content\/uploads\/2015\/06\/Enter-title-here.png 718w, https:\/\/binaryone.com.au\/23\/wp-content\/uploads\/2015\/06\/Enter-title-here-300x53.png 300w\" sizes=\"auto, (max-width: 718px) 100vw, 718px\" \/><\/a><\/figure>\n\n\n\n<p>I 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.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><a href=\"https:\/\/192.168.0.150\/23\/wp-content\/uploads\/2015\/06\/Add-New-Customer-Here.png\"><img loading=\"lazy\" decoding=\"async\" width=\"717\" height=\"128\" src=\"https:\/\/192.168.0.150\/23\/wp-content\/uploads\/2015\/06\/Add-New-Customer-Here.png\" alt=\"Add New Customer Here\" class=\"wp-image-1551\" srcset=\"https:\/\/binaryone.com.au\/23\/wp-content\/uploads\/2015\/06\/Add-New-Customer-Here.png 717w, https:\/\/binaryone.com.au\/23\/wp-content\/uploads\/2015\/06\/Add-New-Customer-Here-300x54.png 300w\" sizes=\"auto, (max-width: 717px) 100vw, 717px\" \/><\/a><\/figure>\n\n\n\n<p>The 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 \u2018Enter title here\u2019 text will be dynamically replaced through WordPress with something like \u2018Add New Customer Here\u2019<\/p>\n\n\n<div class=\"wp-block-ub-content-toggle wp-block-ub-content-toggle-block\" id=\"ub-content-toggle-block-1ff6bd64-fd64-45c7-9384-3454077870cf\" data-mobilecollapse=\"false\" data-desktopcollapse=\"false\" data-preventcollapse=\"false\" data-showonlyone=\"false\">\n<div class=\"wp-block-ub-content-toggle-accordion\" style=\"border-color: #19294e; \" id=\"ub-content-toggle-panel-block-\">\n\t\t\t<div class=\"wp-block-ub-content-toggle-accordion-title-wrap\" style=\"background-color: #19294e;\" aria-controls=\"ub-content-toggle-panel-0-1ff6bd64-fd64-45c7-9384-3454077870cf\" tabindex=\"0\">\n\t\t\t<p class=\"wp-block-ub-content-toggle-accordion-title ub-content-toggle-title-1ff6bd64-fd64-45c7-9384-3454077870cf\" style=\"color: #ffffff; --ub-content-toggle-title-link-color: #ffffff; \">Functions.php<\/p>\n\t\t\t<div class=\"wp-block-ub-content-toggle-accordion-toggle-wrap right\" style=\"color: #f2f2f2;\"><span class=\"wp-block-ub-content-toggle-accordion-state-indicator wp-block-ub-chevron-down open\"><\/span><\/div>\n\t\t<\/div>\n\t\t\t<div role=\"region\" aria-expanded=\"true\" class=\"wp-block-ub-content-toggle-accordion-content-wrap\" id=\"ub-content-toggle-panel-0-1ff6bd64-fd64-45c7-9384-3454077870cf\">\n\n<p>function change_default_title( $title ){<br>\u00a0\u00a0\u00a0\u00a0 global $post;<br>\u00a0\u00a0\u00a0\u00a0 $enter_title_text = esc_html( get_admin_page_title() ).&#8217; Here&#8217;;<br>\u00a0\u00a0\u00a0\u00a0 return $enter_title_text;<br>}<\/p>\n\n\n\n<p>add_filter( &#8216;enter_title_here&#8217;, &#8216;change_default_title&#8217; );<\/p>\n\n<\/div>\n\t\t<\/div>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>The 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 \u2018Enter title here\u2019 text will be dynamically replaced through WordPress with something like \u2018Add New Customer Here\u2019<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[28],"tags":[255,256,257,258,259,260,261,262,263,123,264,85,29],"class_list":["post-1544","post","type-post","status-publish","format-standard","hentry","category-wordpress","tag-cms","tag-content-management-system","tag-custom-content-types","tag-custom-fields","tag-dynamically","tag-enter-title-here","tag-ifthen-statement","tag-page","tag-php","tag-plugin","tag-pods-framework","tag-post","tag-wordpress-2"],"aioseo_notices":[],"featured_image_src":null,"author_info":{"display_name":"Allan","author_link":"https:\/\/binaryone.com.au\/23\/author\/allan-cheesman-binaryone\/"},"_links":{"self":[{"href":"https:\/\/binaryone.com.au\/23\/wp-json\/wp\/v2\/posts\/1544","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/binaryone.com.au\/23\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/binaryone.com.au\/23\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/binaryone.com.au\/23\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/binaryone.com.au\/23\/wp-json\/wp\/v2\/comments?post=1544"}],"version-history":[{"count":6,"href":"https:\/\/binaryone.com.au\/23\/wp-json\/wp\/v2\/posts\/1544\/revisions"}],"predecessor-version":[{"id":2438,"href":"https:\/\/binaryone.com.au\/23\/wp-json\/wp\/v2\/posts\/1544\/revisions\/2438"}],"wp:attachment":[{"href":"https:\/\/binaryone.com.au\/23\/wp-json\/wp\/v2\/media?parent=1544"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/binaryone.com.au\/23\/wp-json\/wp\/v2\/categories?post=1544"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/binaryone.com.au\/23\/wp-json\/wp\/v2\/tags?post=1544"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}