1
How to Disable / Enable Cron Job Services in WordPress
2
How to Disable/Enable WordPress Automatic Updates
3
Adding Specific Class to First Post of a Post Loop
4
How to Call TinyMCE Editor in a WordPress plugin
5
How to remove deprecated errors while running new php versions
6
Find the latest post for each author and then group the results
7
Get the current page name in WordPress using $pagename
8
How to Create a folder in wordpress if it doesn’t already exist
9
How to Redirect WordPress Admin Pages to Any Location You Want
10
How to Hide/Remove the Buttons From Attachment Media Window in WordPress

How to Disable / Enable Cron Job Services in WordPress

With the following code snippet, you’ll be able to disable or enable cron job services in WordPress. Cron job is a scheduling feature in WordPress to schedule posts, pages etc. Paste the code inside wp-config.php file. Disable Cron Job in WordPress define('DISABLE_WP_CRON', true); Enable Cron Job in WordPress Simply remove the above code from wp-config.php,[…]

Read More

How to Disable/Enable WordPress Automatic Updates

If you’re not ready to update the next version of WordPress. Then just add one line inside wp-config.php, and disable / enable wordpress automatic updates. Open your wp-config.php and paste the following code to turn off wordpress automatic updates: define( 'WP_AUTO_UPDATE_CORE', false ); Enable WordPress Automatic Updates Remove the above code, or place ‘true‘. define([…]

Read More

Adding Specific Class to First Post of a Post Loop

Following is a code snippet to add a specific class, for example “my_class” to the first post of a post loop. You’ll have to insert the code inside functions.php. So, “my_class” class will be added to the first post of every post loop, you’re running. <?php add_filter( 'post_class', 'be_first_post_class' ); function be_first_post_class( $classes ) {[…]

Read More

How to Call TinyMCE Editor in a WordPress plugin

If you’re developing a WordPress plugin, and in any part of your plugin you want to show tinyMCE editor, then following is a code snippet to Call TinyMCE Editor in a WordPress plugin. The following code will help you to attach the tinyMCE editor to a textarea in wordpress: add_action("admin_head","load_custom_wp_tiny_mce"); function load_custom_wp_tiny_mce() { if (function_exists('wp_tiny_mce'))[…]

Read More

How to remove deprecated errors while running new php versions

If you’re running PHP code on the server having latest version of PHP, and you’re using deprecated code of PHP. Then, you might get the error something like below: Deprecated: Assigning the return value of new by reference is deprecated Note: Errors code be different, but for deprecated error, the error will have Deprecated written.[…]

Read More

Find the latest post for each author and then group the results

Following is a WordPress database query to fetch the latest post for each author and then group the result. By using this query, you’ll be able to only get a single latest post from each author. Here is the code for displaying only one latest post from each author: SELECT wp_posts.* FROM wp_posts WHERE wp_posts.post_status='publish'[…]

Read More

Get the current page name in WordPress using $pagename

Following is a code snippet to get the current page name in WordPress using $pagename. The global variable $pagename is in the wp-includes/theme.php, and you can find inside get_page_template() function. $pagename variable is called before your page theme files are execute. When you should use $pagename WordPress global variable? 1. The variable is only set[…]

Read More

How to Create a folder in wordpress if it doesn’t already exist

Sometimes working with WordPress, you find out that your (wp-content/uploads) folder or any folder is missing. So, you might feel that you should create a code in theme that checks for the folder and if not found creates it. Following is a sample code for creating a folder in wordpress if it doesn’t already exist.[…]

Read More

How to Redirect WordPress Admin Pages to Any Location You Want

If you are facing a situation to redirect WordPress admin pages to some location. The following code will allow you redirect any admin page you want to any location according to the user “capability or role“. Paste the code inside functions.php. function wpulti_admin_pages_redirect() { global $pagenow; $admin_pages = array( 'edit-tags.php?taxonomy=category', 'edit-tags.php?taxonomy=post_tag', 'link-manager.php', 'options-writing.php', 'options-reading.php', 'options-discussion.php',[…]

Read More