Category: wordpress admin

  • 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!

  • Allow Users to Login With Email Address in WordPress

    How to Allow Users to Login With Email Address in WordPress

    WordPress by default assign a unique username to each user on registration. As usernames are unique on a WordPress website, there is a fine possibility that the username a user wants to register has already been taken by another user, in that case, he have to choose a different username that user might not rememberlater. And if they don’t remember their username then it will be very hard for them to login to your website. I am sure, you must have faced similar situation in past and know how frustrating this is.

    The following snippet will help you fix this issue. Now, your users will be able to login with email addressassigned to their account. We will use wp_authenticate action for this purpose since it runs before WordPress tries to authenticate the user details. We will change the default authentication method used by WordPress and force it to check for email address against user submitted username.

    To allow users to login with email address, simply paste this code snippet in your theme’s functions.php file.

    https://web.archive.org/web/20220521004225if_/https://googleads.g.doubleclick.net/pagead/ads?client=ca-pub-7443478584383873&output=html&h=280&slotname=3463695748&adk=2899339934&adf=2615313419&pi=t.ma~as.3463695748&w=336&lmt=1775835312&psa=0&format=336×280&url=https%3A%2F%2Fwpcodesnippet.com%2Flogin-with-email-address-in-wordpress%2F&wgl=1&dt=1653093751444&bpp=1&bdt=6481&idt=2752&shv=r20220613&mjsv=m202206140101&ptt=9&saldr=aa&abxe=1&prev_fmts=336×280%2C300x250%2C0x0&nras=1&correlator=8483018775109&frm=20&pv=1&ga_vid=490464046.1653093755&ga_sid=1653093755&ga_hid=325795584&ga_fc=0&u_tz=0&u_his=7&u_h=926&u_w=428&u_ah=926&u_aw=428&u_cd=24&u_sd=1&adx=30&ady=1767&biw=428&bih=781&scr_x=0&scr_y=0&eid=44759875%2C44759926%2C44759842%2C31067933%2C31067628%2C31068039%2C42531605%2C31064019&oid=2&pvsid=1214473788402877&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=eS4GjdNTDZ&p=https%3A//web.archive.org&dtd=6934

    // Allow users to login with email address
    function wpcs_login_email_address( &$username, &$password ) {
        $user = get_user_by( 'email', $username );
        if( !empty( $user->user_login ) ) {
            $username = $user->user_login;
        }
    }
    add_action( 'wp_authenticate', 'wpcs_login_email_address' );
  • Add Featured Post Thumbnails to WordPress Admin Post Columns

    How to Add Featured Post Thumbnails to WordPress Admin Post Columns

    Have you ever wanted to see the featured post thumbnails associated with your posts, without going through each post individually? Wouldn’t it be nice if you can see all post thumbnails while viewing the list of posts in the WordPress admin? If you want this feature to add in your website then you are in luck because we just have a perfect solution for you. We have a code snippet that does just that by adding an additional column to the list of posts and pages in WordPress admin and displays the featured post thumbnails in it.

    WordPress filters mange_posts_columns and manage_posts_custom_column allow us to add custom columns to the list of post & pages in the WordPress admin. These two filters control which columns should be displayed when a user views the list of posts or pages. So we used these functions to add an additional column to the list of posts and pages for displaying featured post thumbnails. You can add this code snippet in your functions.php file of your current theme.

    https://web.archive.org/web/20220521000428if_/https://googleads.g.doubleclick.net/pagead/ads?client=ca-pub-7443478584383873&output=html&h=280&slotname=3463695748&adk=383361705&adf=3150202812&pi=t.ma~as.3463695748&w=336&lmt=1775834539&psa=0&format=336×280&url=http%3A%2F%2Fwpcodesnippet.com%2Fadd-featured-post-thumbnails-to-post-columns%2F&wgl=1&dt=1653091490865&bpp=1&bdt=22903&idt=1882&shv=r20220613&mjsv=m202206140101&ptt=9&saldr=aa&abxe=1&prev_fmts=336×280%2C300x250%2C0x0&nras=1&correlator=3431599922232&frm=20&pv=1&ga_vid=1836101822.1653091494&ga_sid=1653091494&ga_hid=20464061&ga_fc=0&u_tz=0&u_his=7&u_h=926&u_w=428&u_ah=926&u_aw=428&u_cd=24&u_sd=1&adx=30&ady=1724&biw=428&bih=781&scr_x=0&scr_y=496&eid=44759875%2C44759926%2C44759842%2C31068039%2C31062930&oid=2&pvsid=3798946907895945&tmod=1118653441&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=4YzxBWuQJk&p=https%3A//web.archive.org&dtd=15838

    // add featured thumbnail to admin post columns
    function wpcs_add_thumbnail_columns( $columns ) {
        $columns = array(
            'cb' => '<input type="checkbox" />',
            'featured_thumb' => 'Thumbnail',
            'title' => 'Title',
            'author' => 'Author',
            'categories' => 'Categories',
            'tags' => 'Tags',
            'comments' => '<span class="vers"><div title="Comments" class="comment-grey-bubble"></div></span>',
            'date' => 'Date'
        );
        return $columns;
    }
    
    function wpcs_add_thumbnail_columns_data( $column, $post_id ) {
        switch ( $column ) {
        case 'featured_thumb':
            echo '<a href="' . get_edit_post_link() . '">';
            echo the_post_thumbnail( 'thumbnail' );
            echo '</a>';
            break;
        }
    }
    
    if ( function_exists( 'add_theme_support' ) ) {
        add_filter( 'manage_posts_columns' , 'wpcs_add_thumbnail_columns' );
        add_action( 'manage_posts_custom_column' , 'wpcs_add_thumbnail_columns_data', 10, 2 );
        add_filter( 'manage_pages_columns' , 'wpcs_add_thumbnail_columns' );
        add_action( 'manage_pages_custom_column' , 'wpcs_add_thumbnail_columns_data', 10, 2 );
    }

    This is a very handy code snippet if you use post thumbnail feature very heavily and don’t want to have to edit each post in order to see the thumbnail being used.

  • How to Add Featured Post Thumbnails to WordPress Admin Post Columns

    Have you ever wanted to see the featured post thumbnails associated with your posts, without going through each post individually? Wouldn’t it be nice if you can see all post thumbnails while viewing the list of posts in the WordPress admin? If you want this feature to add in your website then you are in luck because we just have a perfect solution for you. We have a code snippet that does just that by adding an additional column to the list of posts and pages in WordPress admin and displays the featured post thumbnails in it.

    WordPress filters mange_posts_columns and manage_posts_custom_column allow us to add custom columns to the list of post & pages in the WordPress admin. These two filters control which columns should be displayed when a user views the list of posts or pages. So we used these functions to add an additional column to the list of posts and pages for displaying featured post thumbnails. You can add this code snippet in your functions.php file of your current theme.

    // add featured thumbnail to admin post columns
    function wpcs_add_thumbnail_columns( $columns ) {
        $columns = array(
            'cb' => '<input type="checkbox" />',
            'featured_thumb' => 'Thumbnail',
            'title' => 'Title',
            'author' => 'Author',
            'categories' => 'Categories',
            'tags' => 'Tags',
            'comments' => '<span class="vers"><div title="Comments" class="comment-grey-bubble"></div></span>',
            'date' => 'Date'
        );
        return $columns;
    }
    
    function wpcs_add_thumbnail_columns_data( $column, $post_id ) {
        switch ( $column ) {
        case 'featured_thumb':
            echo '<a href="' . get_edit_post_link() . '">';
            echo the_post_thumbnail( 'thumbnail' );
            echo '</a>';
            break;
        }
    }
    
    if ( function_exists( 'add_theme_support' ) ) {
        add_filter( 'manage_posts_columns' , 'wpcs_add_thumbnail_columns' );
        add_action( 'manage_posts_custom_column' , 'wpcs_add_thumbnail_columns_data', 10, 2 );
        add_filter( 'manage_pages_columns' , 'wpcs_add_thumbnail_columns' );
        add_action( 'manage_pages_custom_column' , 'wpcs_add_thumbnail_columns_data', 10, 2 );
    }

    This is a very handy code snippet if you use post thumbnail feature very heavily and don’t want to have to edit each post in order to see the thumbnail being used.