1
How to Display WordPress $hook_suffix as Admin Notice
2
Hide/Exclude a Page in Edit Pages Section in WordPress Dashboard
3
How to Add Google Trends Graph in Post/Page via Shortcode
4
How to Add body_class to Specific WordPress Page Templates
5
Stop Disqus JavaScript on All WordPress Pages Except Posts or Pages
6
Define Minimum Comment Length in WordPress Comments
7
How to Add Custom Field Dynamically to WordPress Post/Page when Published
8
How to Change WordPress Admin Post / Page Color by Status (Private, Future, Published … )
9
How to add nofollow attribute to WordPress category specific links
10
How to Trim WordPress Text / Words with wp_trim_words()

How to Display WordPress $hook_suffix as Admin Notice

Hook Suffix is page in WordPress and that is generated everytime you add  a new admin menu, for example, add_submenu_page(), add_menu_page(), add_options_page(). These kind of functions returns a special value called Page Hook Suffix. If you are looking for a way to use the hook_suffix later, register a hook on a particular page load-hook_suffix. Following[…]

Read More

How to Add Google Trends Graph in Post/Page via Shortcode

wordpress logo

Google Trends is a service provided by Google Inc. This service shows the most searched term, based on Google Search. Google also provides an API to display Google trends in any website. But we’ll implement Google Trends in WordPress by creating a shortcut for Google Trends. Paste the following code in functions.php. The code will[…]

Read More

How to Add body_class to Specific WordPress Page Templates

wordpress logo

body_class is a template tag in WordPress helping us to style our themes more effectively with CSS. This function automatically add different classes to your element. We usually use it inside header.php like: <body <?php body_class($class); ?> > If you’ll add above code to header.php, it will apply to all WordPress pages. But what you[…]

Read More

Define Minimum Comment Length in WordPress Comments

wordpress logo

Here, we’ll show you how to define minimum comment length in WordPress. Just paste the code to the functions.php file of your theme. You just have to define the minimum length of WordPress comments and that’s it. WordPress will handle everything by itself using wp_die, if a comment doesn’t reach your minimum criteria. add_filter( 'execute_comment',[…]

Read More

How to Change WordPress Admin Post / Page Color by Status (Private, Future, Published … )

wordpress logo

Use the following code in WordPress theme’s functions.php. This will change the background colors of your choice for post or page within your WordPress admin dashboard based on the post’s current status. For now, we just know 5 statuses for post or page: Private, Future, Published, Pending and Draft. <?php add_action('admin_footer','posts_status_color'); function posts_status_color(){ ?> <style>[…]

Read More

How to add nofollow attribute to WordPress category specific links

wordpress logo

If you are linking any WordPress category inside your post editor, you can make dynamically make them nofollow. Following code snippet will help you to add the nofollow attribute to the category links coming from the_content(). Paste the following code inside your functions.php. function nofollow_cat_links($text) { global $post; // Speicify Category ID here if( in_category(3)[…]

Read More

How to Trim WordPress Text / Words with wp_trim_words()

wordpress logo

WordPress introduced a new function wp_trim_words(). This is helpful to trim the text to a specific number of words. You can use this function for the_title(), the_content() and the_excerpt() in your post’s loop. Put the following code in your loop. //For post title echo wp_trim_words(get_the_title(), 50); //For excerpt echo wp_trim_words(get_the_excerpt(), 50); //For content echo wp_trim_words(get_the_content(),[…]

Read More