Author: adminword

  • Prevent User Registration in WordPress From Specific Domain

    How to Prevent User Registration in WordPress From Specific Domain

    Usually it’s a good idea to disable user registration in WordPress, if you do not use membership feature, since spammers can attack your website with spam user registrations. One of my clients had enabled the option “anyone can register” in WordPress settings and allowed visitors to register. Within as week, he received couple of user signups but soon after he started to receive user registrations, hundreds in number from one specific domain. That made him realize, all user were essentially spam registrations.

    After couple of attempts, I was able to block spam user registrations from this specific domain. I used registration_errors hook in WordPress which filters the errors encountered when a new user is being registered. If any errors are present, WordPress will abort the user’s registration. This filter can also be used to create custom validation rules on user registration. This hook fires when the form is submitted but before user information is saved to the database. So I created custom rule to check user’s email domain and provide error if user’s email match blacklisted domain.

    Here is the function you can dump in your theme’s functions.php file. The following function will prevent user registration if WordPress find “domain.Com” in user’s email address.

    https://web.archive.org/web/20220701035414if_/https://googleads.g.doubleclick.net/pagead/ads?client=ca-pub-7443478584383873&output=html&h=280&slotname=3463695748&adk=3644181001&adf=3895680182&pi=t.ma~as.3463695748&w=336&lmt=1775837011&psa=0&format=336×280&url=https%3A%2F%2Fwpcodesnippet.com%2Fprevent-user-registration-from-specific-domain%2F&wgl=1&dt=1656647656319&bpp=1&bdt=2332&idt=670&shv=r20220613&mjsv=m202206090101&ptt=9&saldr=aa&abxe=1&prev_fmts=336×280&correlator=2056607088951&frm=20&pv=1&ga_vid=1651040783.1656647658&ga_sid=1656647658&ga_hid=1564925315&ga_fc=0&u_tz=0&u_his=8&u_h=926&u_w=428&u_ah=926&u_aw=428&u_cd=24&u_sd=1&adx=30&ady=1892&biw=428&bih=781&scr_x=0&scr_y=0&eid=44759875%2C44759926%2C44759837%2C42531556%2C44761043%2C31067528%2C31067629%2C42531605&oid=2&pvsid=377500802098776&tmod=4619812&uas=0&nvt=1&eae=0&fc=896&brdim=0%2C0%2C0%2C0%2C428%2C0%2C428%2C926%2C428%2C781&vis=1&rsz=%7C%7CoeEbr%7C&abl=CS&pfx=0&fu=0&bc=31&ifi=2&uci=a!2&btvi=1&fsb=1&xpc=i9C4k2rVlP&p=https%3A//web.archive.org&dtd=1682

    // prevent user registration in wordpress from specific domain
    function wpcs_disable_email_domain ( $errors, $sanitized_user_login, $user_email ) {
        list( $email_user, $email_domain ) = explode( '@', $user_email );
        if ( $email_domain == 'domain.com' ) {
            $errors->add( 'email_error', __( '<strong>ERROR</strong>: Domain not allowed.', 'my_domain' ) );
        }
        return $errors;
    }
    add_filter( 'registration_errors', 'wpcs_disable_email_domain', 10, 3 );

    Simple. Right!

  • Get A List Of All Custom Page Templates in WordPress

    How to Get A List Of All Custom Page Templates in WordPress

    Pages are one of WordPress’s built-in Post Types. You’ll probably want most of your website Pages to look about the same. But sometimes, though, you may need a specific Page, or a group of Pages, to display or behave differently. This is easily accomplished with custom Page Templates. WordPress allows you to create custom page templates to use throughout your site, using these custom page templates you can completely change the look and functionality of a certain page.

    If you are developing something for WordPress and need to get a list of all custom page templates that currently exist on the WordPress theme then you can use the following code snippet. This WordPress code snippet returns all the custom Page Templates available to the currently activated WordPress theme as an array. Each array item has a key of the Template Name and value of the filename (or folder-name and filename for custom page templates stored in a theme’s subdirectory). What it actually does is, it searches all the current theme’s template files for the commented “Template Name: name of template” and returns in an array for further uses.

    You can use this method in your theme files to get a list of all custom page templates in currently activated WordPress theme.

    https://web.archive.org/web/20220701041818if_/https://googleads.g.doubleclick.net/pagead/ads?client=ca-pub-7443478584383873&output=html&h=280&slotname=3463695748&adk=2198418996&adf=1178846890&pi=t.ma~as.3463695748&w=336&lmt=1775836779&psa=0&format=336×280&url=https%3A%2F%2Fwpcodesnippet.com%2Fget-list-custom-page-templates-wordpress%2F&wgl=1&dt=1656649101823&bpp=2&bdt=3859&idt=1496&shv=r20220613&mjsv=m202206090101&ptt=9&saldr=aa&abxe=1&prev_fmts=336×280&correlator=2440644329311&frm=20&pv=1&ga_vid=1960743515.1656649104&ga_sid=1656649104&ga_hid=1005822866&ga_fc=0&u_tz=0&u_his=8&u_h=926&u_w=428&u_ah=926&u_aw=428&u_cd=24&u_sd=1&adx=30&ady=1867&biw=428&bih=781&scr_x=0&scr_y=0&eid=44759875%2C44759926%2C44759837%2C31065545%2C31067528%2C42531606&oid=2&pvsid=2461052713038252&tmod=4619812&uas=0&nvt=1&eae=0&fc=896&brdim=0%2C0%2C0%2C0%2C428%2C0%2C428%2C926%2C428%2C781&vis=1&rsz=%7C%7CoeEbr%7C&abl=CS&pfx=0&fu=0&bc=31&ifi=2&uci=a!2&btvi=1&fsb=1&xpc=WLVzFgoz5P&p=https%3A//web.archive.org&dtd=2544

    <?php
    
        // get a list of all custom page templates in wordpress
        $themeObj = wp_get_theme();
        $templates = $themeObj->get_page_templates();
    
        echo "<ul>";
        foreach ( $templates as $template_name => $template_filename ) {
            echo "<li>" . $template_name . "(" . $template_filename . ")</li>";
        }
        echo "</ul>";
    
    ?>
  • Force Sub Categories To Use Parent Category Templates

    How to Force Sub Categories To Use Parent Category Templates

    When a viewer clicks on a link to one of the Categorieson your WordPress site, he or she is taken to a page listing the Posts in that particular Category in chronological order. WordPress uses `category.php` template as a default layout to display all category listing pages. But you also have option to define your own custom category templates too. Defining template for a particular category is easy. All you have to do is create a file named as `category-{category-slug}.php`. So if your category slug is “news” then your category template name will be `category-news.php`. In a recent project I was required to define category template for a parent category, and then had to make sure that all the child categories under that parent must inherit the same template used by the parent category.

    To solve my little problem I created this following function which uses category_template WordPress filter to assign parent category template to all child categories and sub-categories. First I got the current category by using the function get_queried_object() and then checked if the current category has a parent category, if it does then it will search for the parent category by using the get_category() function, if this isn’t empty then we add the extra templates to the array using the parent slug and parent ID.

    Simply pasting this WordPress code snippet in your theme’s functions.php file will force WordPress to use parent category templates on all sub-categories.

    https://web.archive.org/web/20220520235047if_/https://googleads.g.doubleclick.net/pagead/ads?client=ca-pub-7443478584383873&output=html&h=280&slotname=3463695748&adk=4210103527&adf=3888359067&pi=t.ma~as.3463695748&w=336&lmt=1775836673&psa=0&format=336×280&url=https%3A%2F%2Fwpcodesnippet.com%2Fforce-sub-categories-use-parent-category-templates%2F&wgl=1&dt=1653090650244&bpp=1&bdt=3261&idt=3339&shv=r20220613&mjsv=m202206140101&ptt=9&saldr=aa&abxe=1&prev_fmts=336×280&correlator=4317920920946&frm=20&pv=1&ga_vid=1934532103.1653090655&ga_sid=1653090655&ga_hid=1935837571&ga_fc=0&u_tz=0&u_his=8&u_h=926&u_w=428&u_ah=926&u_aw=428&u_cd=24&u_sd=1&adx=30&ady=1967&biw=428&bih=781&scr_x=0&scr_y=0&eid=44759875%2C44759926%2C44759842%2C31067628%2C31067769%2C31068039&oid=2&pvsid=2466593407024257&tmod=1118653441&uas=0&nvt=1&eae=0&fc=896&brdim=0%2C0%2C0%2C0%2C428%2C0%2C428%2C926%2C428%2C781&vis=1&rsz=%7C%7CoeEbr%7C&abl=CS&pfx=0&fu=0&bc=31&ifi=2&uci=a!2&btvi=1&fsb=1&xpc=DvNYR5mone&p=https%3A//web.archive.org&dtd=4351

    // force sub categories to use parent category templates
    function wcs_force_use_parent_category_template() {
    
        $category = get_queried_object();
        $templates = array();
    
        // Add default category template files
        $templates[] = "category-{$category->slug}.php";
        $templates[] = "category-{$category->term_id}.php";
    
        if ( $category->category_parent != 0 ) {
            $parent = get_category( $category->category_parent );
    
            if ( !empty($parent) ) {
                $templates[] = "category-{$parent->slug}.php";
                $templates[] = "category-{$parent->term_id}.php";
            }
        }
    
        $templates[] = 'category.php';
        return locate_template( $templates );
    }
    add_filter( 'category_template', 'wcs_force_use_parent_category_template' );
  • Remove Version Query String From Static JS And CSS Files

    How to Remove Version Query String From Static JS And CSS Files

    A website owner should always be trying to improve the speed of their website as much as possible. When you analyze your page using any page speed analyzer such as Page Speed, YSlow or Pingdom, you are very likely to see suggestions to remove query strings from static resources, such as Stylesheets and JavaScript files. This is a problem as many proxies will not cache the resources if it has a query string in the URL. A tip on the Google best practice pages is to remove all query strings from your static resources to enable proxy caching of the file. So in this article I will show you how you can easily remove version query string from static scripts and stylesheets.

    Most of the stylesheets and JavaScript files added by WordPress plugins and themes usually have version query string (?ver=) in their URL. And we want to remove version query string from these static resources to make our pages and static resource to cache so that the pages can load faster. There are a couple of plugins in WordPress respiratory that does this job but this is an easy enough task to use plugin.

    Just paste this following WordPress snippet in your theme’s functions.php file to remove version query string from static scripts and stylesheets resources. Once you are done adding this snippet in your theme, head back to analyze your page again and notice the difference.

    https://web.archive.org/web/20220701054219if_/https://googleads.g.doubleclick.net/pagead/ads?client=ca-pub-7443478584383873&output=html&h=280&slotname=3463695748&adk=2171063462&adf=4260535974&pi=t.ma~as.3463695748&w=336&lmt=1775836510&psa=0&format=336×280&url=http%3A%2F%2Fwpcodesnippet.com%2Fremove-version-query-string-static-js-css-files%2F&wgl=1&dt=1656654141627&bpp=1&bdt=2660&idt=1111&shv=r20220613&mjsv=m202206090101&ptt=9&saldr=aa&abxe=1&prev_fmts=336×280&correlator=866940032436&frm=20&pv=1&ga_vid=2014663794.1656654144&ga_sid=1656654144&ga_hid=2026761337&ga_fc=0&u_tz=0&u_his=8&u_h=926&u_w=428&u_ah=926&u_aw=428&u_cd=24&u_sd=1&adx=30&ady=1714&biw=428&bih=781&scr_x=0&scr_y=0&eid=44759875%2C44759926%2C44759837%2C31067528%2C31067629%2C31068030%2C31062930&oid=2&pvsid=1571916119939077&tmod=4619812&uas=0&nvt=1&eae=0&fc=896&brdim=0%2C0%2C0%2C0%2C428%2C0%2C428%2C926%2C428%2C781&vis=1&rsz=%7C%7CoeEbr%7C&abl=CS&pfx=0&fu=0&bc=31&ifi=2&uci=a!2&btvi=1&fsb=1&xpc=2VD5mXF85c&p=https%3A//web.archive.org&dtd=2142

    // remove version query string from scripts and stylesheets
    function wcs_remove_script_styles_version( $src ){
        return remove_query_arg( 'ver', $src );
    }
    add_filter( 'script_loader_src', 'wcs_remove_script_styles_version' );
    add_filter( 'style_loader_src', 'wcs_remove_script_styles_version' );
  • Add Custom Image Sizes Into WordPress Media Library

    How to Add Custom Image Sizes Into WordPress Media Library

    In a previous article we have posted about how you can define new custom image sizes to use on your WordPress theme and how to remove default image sizes. You can define and add custom image sizes with the help of add_image_size() function in WordPress. In this article we will show you how you can add these pre-defined custom image sizes to media library upload panel so that you can choose from all available image sizes instead of only standard thumbnail, medium, large and full sizes.

    We want the content editor to be able to select these new sizes when adding an image into the post, by default when using add_image_size() these custom image sizes won’t appear when inserting into the post. For this we need to use the filter image_size_name_choose and make sure we add the custom image sizes into the size array. Adding the new custom image sizes into this array will make sure that the editor can pick these new sizes and that the images will still fit the design of the theme.

    Simply add the following WordPress code snippet into your theme’s functions.php file to allow the editors to choose these new sizes.

    https://web.archive.org/web/20220701042026if_/https://googleads.g.doubleclick.net/pagead/ads?client=ca-pub-7443478584383873&output=html&h=280&slotname=3463695748&adk=3881983570&adf=1219422936&pi=t.ma~as.3463695748&w=336&lmt=1775836305&psa=0&format=336×280&url=http%3A%2F%2Fwpcodesnippet.com%2Fadd-custom-image-sizes-wordpress-media-library%2F&wgl=1&dt=1656649229768&bpp=1&bdt=3800&idt=1266&shv=r20220613&mjsv=m202206090101&ptt=9&saldr=aa&abxe=1&prev_fmts=336×280&correlator=4294693926340&frm=20&pv=1&ga_vid=998311421.1656649232&ga_sid=1656649232&ga_hid=2106914544&ga_fc=0&u_tz=0&u_his=8&u_h=926&u_w=428&u_ah=926&u_aw=428&u_cd=24&u_sd=1&adx=30&ady=1792&biw=428&bih=781&scr_x=0&scr_y=0&eid=44759875%2C44759926%2C44759837%2C44766068&oid=2&pvsid=2260101201887277&tmod=4619812&uas=0&nvt=1&eae=0&fc=896&brdim=0%2C0%2C0%2C0%2C428%2C0%2C428%2C926%2C428%2C781&vis=1&rsz=%7C%7CoeEbr%7C&abl=CS&pfx=0&fu=0&bc=31&ifi=2&uci=a!2&btvi=1&fsb=1&xpc=2wcIN6S18X&p=https%3A//web.archive.org&dtd=2255

    // add custom image sizes into wordpress media library
    function display_custom_image_sizes( $sizes ) {
        global $_wp_additional_image_sizes;
        if ( empty( $_wp_additional_image_sizes ) )
            return $sizes;
    
        foreach ( $_wp_additional_image_sizes as $id => $data ) {
            if ( !isset($sizes[$id]) )
                $sizes[$id] = ucfirst( str_replace( '-', ' ', $id ) );
        }
    
        return $sizes;
    }
    add_filter( 'image_size_names_choose', 'display_custom_image_sizes' );
  • Redirect User To Post If Search Results Return One Post

    How to Redirect User To Post If Search Results Return One Post

    Recently on a project, my client asked me to develop a system to redirect user to post if search results returns only one post. Although it’s fairly simple system to develop but I started searching on Google if someone has already tried to develop similar function. Fortunately WordPress developer Paul Underwood has shared a WordPress code snippet for this on his website. All I had to do is to use his snippet and modify it further for my client’s requirements. I also thought it would be nice to share it with you guys since it’s really nice feature to have on your website to redirect user to post directly if search results only return one post. You may also like to add search form in your post content by using shortcode.

    Paul used template_redirect WordPress action in his WordPress snippet to check if the user is searching and if there is only one search result is returned then redirect user to the post directly instead of showing search results. So here is the function, which you can simply paste in your theme’s functions.php file. You don’t need to modify anything in this code snippet as it will work out of the box and redirect user to post if only one search result available.

    https://web.archive.org/web/20220521002628if_/https://googleads.g.doubleclick.net/pagead/ads?client=ca-pub-7443478584383873&output=html&h=280&slotname=3463695748&adk=3707011748&adf=2145559993&pi=t.ma~as.3463695748&w=336&lmt=1775836198&psa=0&format=336×280&url=https%3A%2F%2Fwpcodesnippet.com%2Fredirect-user-to-post-search-results-return-one-post%2F&wgl=1&dt=1653092791082&bpp=1&bdt=3101&idt=1147&shv=r20220613&mjsv=m202206140101&ptt=9&saldr=aa&abxe=1&prev_fmts=336×280&correlator=8485658206314&rume=1&frm=20&pv=1&ga_vid=2005826425.1653092793&ga_sid=1653092793&ga_hid=1428903289&ga_fc=0&u_tz=0&u_his=8&u_h=926&u_w=428&u_ah=926&u_aw=428&u_cd=24&u_sd=1&adx=30&ady=1799&biw=428&bih=781&scr_x=0&scr_y=0&eid=44759875%2C44759926%2C44759842%2C31065742%2C31067769%2C31068039%2C31061691%2C31061692&oid=2&pvsid=2264599395959539&tmod=1118653441&uas=0&nvt=1&eae=0&fc=896&brdim=0%2C0%2C0%2C0%2C428%2C0%2C428%2C926%2C428%2C781&vis=1&rsz=%7C%7CoeEbr%7C&abl=CS&pfx=0&fu=0&bc=31&ifi=2&uci=a!2&btvi=1&fsb=1&xpc=aSTT6ruZ8l&p=https%3A//web.archive.org&dtd=2176

    // redirect user to post if search results return one post
    function redirect_single_post() {
        if ( is_search() && is_main_query() ) {
            global $wp_query;
            if ( $wp_query->post_count == 1 && $wp_query->max_num_pages == 1 ) {
                wp_redirect( get_permalink( $wp_query->posts['0']->ID ) );
                exit;
            }
        }
    }
    add_action( 'template_redirect', 'redirect_single_post' );
  • Limit WordPress To Perform Search Through Post Titles Only

    How to Limit WordPress To Perform Search Through Post Titles Only

    On a project, sometimes you may require WordPress to perform search through post titles only and exclude post content as well as post excerpts. Although it’s not very useful to exclude post content from searches because then you will get less relevant results and also less results in quantity, but on a special project you might want this unique feature. So in this topic I will post a way to perform search through post titles only.

    We can achieve this with standard posts_searchWordPress filter. With this filter we can modify the default behavior of search in WordPress. First we will check if search returns empty results and in that case, we will skip the process any further. But in case of non-empty search results, we will run SQL query to match keywords against post title and return the results accordingly. So following is the function to search through post titles only. You must add this WordPress code snippet in your theme’s functions.php file to apply search filter.

    https://web.archive.org/web/20220615215933if_/https://googleads.g.doubleclick.net/pagead/ads?client=ca-pub-7443478584383873&output=html&h=280&slotname=3463695748&adk=289409493&adf=813681637&pi=t.ma~as.3463695748&w=336&lmt=1775836057&psa=0&format=336×280&url=http%3A%2F%2Fwpcodesnippet.com%2Flimit-wordpress-search-through-post-titles-only%2F&wgl=1&dt=1655330376989&bpp=1&bdt=4025&idt=1289&shv=r20220613&mjsv=m202206090101&ptt=9&saldr=aa&abxe=1&prev_fmts=336×280&correlator=4073773534463&frm=20&pv=1&ga_vid=1686314600.1655330379&ga_sid=1655330379&ga_hid=830106269&ga_fc=0&u_tz=0&u_his=8&u_h=926&u_w=428&u_ah=926&u_aw=428&u_cd=24&u_sd=1&adx=30&ady=1521&biw=428&bih=781&scr_x=0&scr_y=0&eid=44759875%2C44759926%2C44759837&oid=2&pvsid=2240814953483028&tmod=4619812&uas=3&nvt=1&eae=0&fc=896&brdim=0%2C0%2C0%2C0%2C428%2C0%2C428%2C926%2C428%2C781&vis=1&rsz=%7C%7CoeEbr%7C&abl=CS&pfx=0&fu=0&bc=31&ifi=2&uci=a!2&btvi=1&fsb=1&xpc=N12u4tVkhw&p=https%3A//web.archive.org&dtd=2283

    // search filter for searching through post titles only
    function wcs_search_by_title_only( $search, &$wp_query ) {
    
        global $wpdb;
    
        if ( empty( $search ) )
            return $search;
    
        $q = $wp_query->query_vars;
        $n = ! empty( $q['exact'] ) ? '' : '%';
    
        $search =
        $searchand = '';
    
        foreach ( (array) $q['search_terms'] as $term ) {
            $term = esc_sql( like_escape( $term ) );
            $search .= "{$searchand}($wpdb->posts.post_title LIKE '{$n}{$term}{$n}')";
            $searchand = ' AND ';
        }
    
        if ( ! empty( $search ) ) {
            $search = " AND ({$search}) ";
            if ( ! is_user_logged_in() )
                $search .= " AND ($wpdb->posts.post_password = '') ";
        }
    
        return $search;
    
    }
    add_filter( 'posts_search', 'wcs_sear
  • Quickly Enable Debug Mode On WordPress Website When Needed

    How to Quickly Enable Debug Mode On WordPress Website When Needed

    If you have ever faced “WordPress white screen of death” then you probably already know that there is something wrong on your website and in situations like this, you must switch ON WordPress debug mode on your website to diagnose the issue. But to enable debug mode, you will require to edit WordPress configurationfile on your production server. And sometimes it’s little too much trouble to access web server and modify wp-config.php file, just to enable debug mode. Well, there is a little hack, we can use that can quickly switch on debug mode on the fly, without even editing configuration file every time.

    This little hack was shared by Joost de Valk on his blog. You must paste the following code snippet in your WordPress configuration file (wp-config.php). It wouldn’t work by adding this code in functions.php since it’s already too late to define WP_DEBUG there.

    https://web.archive.org/web/20220701050311if_/https://googleads.g.doubleclick.net/pagead/ads?client=ca-pub-7443478584383873&output=html&h=280&slotname=3463695748&adk=2272764864&adf=541837517&pi=t.ma~as.3463695748&w=336&lmt=1775835922&psa=0&format=336×280&url=https%3A%2F%2Fwpcodesnippet.com%2Fquickly-enable-debug-mode-on-wordpress-when-needed%2F&wgl=1&dt=1656651797352&bpp=2&bdt=6388&idt=19069&shv=r20220613&mjsv=m202206090101&ptt=9&saldr=aa&abxe=1&prev_fmts=336×280&correlator=2468546887766&frm=20&pv=1&ga_vid=928066453.1656651817&ga_sid=1656651817&ga_hid=89128672&ga_fc=0&u_tz=0&u_his=8&u_h=926&u_w=428&u_ah=926&u_aw=428&u_cd=24&u_sd=1&adx=30&ady=1471&biw=428&bih=781&scr_x=0&scr_y=402&eid=44759875%2C44759926%2C44759837&oid=2&pvsid=1071438939126522&tmod=4619812&uas=0&nvt=1&eae=0&fc=896&brdim=0%2C0%2C0%2C0%2C428%2C0%2C428%2C926%2C428%2C821&vis=1&rsz=%7C%7CoeEbr%7C&abl=CS&pfx=0&fu=0&bc=31&ifi=2&uci=a!2&btvi=1&fsb=1&xpc=iHJqOqx221&p=https%3A//web.archive.org&dtd=20098

    // enable debug mode
    if ( isset( $_GET['debug'] ) && 'secret-key' == $_GET['debug'] ) {
        define( 'WP_DEBUG', true );
        define( 'SCRIPT_DEBUG', true );
    }

    Now you can open any page, and if something goes wrong there, like a white screen of death, you can add ?debug=secret-key to its URL and can access the debug logs and know what’s causing the trouble.

    It’s important to note that anyone can access this information if they know your secret-key, so it would be wise to change that phrase ‘secret-key’ to a key of your own choosing, so not everyone out there can enable debug mode on your blog.

  • Display All Tags on Post Edit Page Instead of Frequently Used Tags

    How to Display All Tags on Post Edit Page Instead of Frequently Used Tags

    WordPress by default shows only 45 frequently used tags on post edit page in WordPress admin. In most of the cases it’s quite fine since most of the users do not have that many tags on their blog. But on a relatively large website, you may have hundreds of tags and you may require WordPress to show them all instead of just showing 45 frequently used tags. In this article we will see how we can force WordPress to show all post tags in place of more frequently used tags.

    This is quite tricky since the number 45 is hard-coded in WordPress core files. Some solution suggests modifying core WordPress files but in that case, updating WordPress will flush out our customization each time and we will have to reapply the changes again.

    The easiest way to accomplish this is to use the get_terms_args filter to modify the AJAX request to get the tag cloud and unset the number limit. Here is the function you can add in your functions.php file to remove number limit.

    https://web.archive.org/web/20220520234917if_/https://googleads.g.doubleclick.net/pagead/ads?client=ca-pub-7443478584383873&output=html&h=280&slotname=3463695748&adk=2764595617&adf=4243700319&pi=t.ma~as.3463695748&w=336&lmt=1775835798&psa=0&format=336×280&url=https%3A%2F%2Fwpcodesnippet.com%2Fdisplay-all-tags-instead-of-frequently-used-tags%2F&wgl=1&dt=1653090566183&bpp=1&bdt=9220&idt=11605&shv=r20220613&mjsv=m202206140101&ptt=9&saldr=aa&abxe=1&prev_fmts=336×280&correlator=80766594880&frm=20&pv=1&ga_vid=1133895002.1653090579&ga_sid=1653090579&ga_hid=489333165&ga_fc=0&u_tz=0&u_his=8&u_h=926&u_w=428&u_ah=926&u_aw=428&u_cd=24&u_sd=1&adx=30&ady=1742&biw=428&bih=781&scr_x=0&scr_y=0&eid=44759875%2C44759926%2C44759842%2C31068039&oid=2&pvsid=1984109002500751&tmod=1118653441&uas=0&nvt=1&eae=0&fc=896&brdim=0%2C0%2C0%2C0%2C428%2C0%2C428%2C926%2C428%2C781&vis=1&rsz=%7C%7CoeEbr%7C&abl=CS&pfx=0&fu=0&bc=31&ifi=2&uci=a!2&btvi=1&fsb=1&xpc=QzZUuGx6S9&p=https%3A//web.archive.org&dtd=12618

    // display all tags on post edit instead of frequently used tags
    function wcs_show_all_tags ( $args ) {
        if ( defined( 'DOING_AJAX' ) && DOING_AJAX && isset( $_POST['action'] ) && $_POST['action'] === 'get-tagcloud' )
            unset( $args['number'] );
        return $args;
    }
    add_filter( 'get_terms_args', 'wcs_show_all_tags' );

    Use can modify above function based on your requirements for this specific project.

  • Change Default “Enter Title Here” Placeholder Text In Post Screen

    How to Change Default “Enter Title Here” Placeholder Text In Post Screen

    By default WordPress displays “Enter title here” placeholder text in the post title field section on the post screen, where you create a new post. But in case of custom post type, while we register our custom post type, there is no parameter or option to change this default placeholder text to provide more personalized touch to our post type titles section. For example if you register a custom post type for books then wouldn’t’ it be nice to have “Enter book name” placeholder text instead of default “Enter title here“. So in this topic I will show you how you can replace default placeholder text with the text you want to use.

    Fortunately WordPress provide an easy way to change title placeholder text. WordPress has a filter named enter_title_here which allows us to change “Enter title here” text in WordPress posts screen and custom post types’ screen. So following code snippet will change “Enter title here” placeholder text to “Enter book name” for Book post types. Just drop the following snippet to your current theme’s functions.php file.

    https://web.archive.org/web/20220615214428if_/https://googleads.g.doubleclick.net/pagead/ads?client=ca-pub-7443478584383873&output=html&h=280&slotname=3463695748&adk=134643800&adf=1411858264&pi=t.ma~as.3463695748&w=336&lmt=1775835658&psa=0&format=336×280&url=http%3A%2F%2Fwpcodesnippet.com%2Fchange-enter-title-here-placeholder-text%2F&wgl=1&dt=1655329471043&bpp=1&bdt=3073&idt=838&shv=r20220613&mjsv=m202206090101&ptt=9&saldr=aa&abxe=1&prev_fmts=336×280&correlator=4622473575869&frm=20&pv=1&ga_vid=262439355.1655329473&ga_sid=1655329473&ga_hid=1167326009&ga_fc=0&u_tz=0&u_his=8&u_h=926&u_w=428&u_ah=926&u_aw=428&u_cd=24&u_sd=1&adx=30&ady=1571&biw=428&bih=781&scr_x=0&scr_y=0&eid=44759875%2C44759926%2C44759837%2C31067628&oid=2&pvsid=158749570198335&tmod=4619812&uas=0&nvt=1&eae=0&fc=896&brdim=0%2C0%2C0%2C0%2C428%2C0%2C428%2C926%2C428%2C781&vis=1&rsz=%7C%7CoeEbr%7C&abl=CS&pfx=0&fu=0&bc=31&ifi=2&uci=a!2&btvi=1&fsb=1&xpc=kWCqRcnrVA&p=https%3A//web.archive.org&dtd=1796

    // change "Enter title here" placeholder text
    function wpcs_change_title_placeholder_text( $title ) {
        $screen = get_current_screen();
        if  ( 'book' == $screen->post_type ) {
            $title = 'Enter book name';
        }
        return $title;
    }
    add_filter( 'enter_title_here', 'wpcs_change_title_placeholder_text' );

    That’s all!