Category: Hacks & Code Snippets

web developer at WPLAB
Website development like the art

First of it all, login to your phpmyadmin and choose your WordPress database. Once done, click on the sql button to open the sql command window. Then, simply paste the following sql command and execute it. DELETE FROM `wp_options` WHERE `option_name` LIKE (‘%_transient_%’); Credit: Stack Overflow Want more super useful SQL queries? Check out this […]

Rating
web developer at WPLAB
Website development like the art

First of it all, login to your phpmyadmin and choose your WordPress database. Once done, click on the sql button to open the sql command window.Then, simply paste the following sql command and execute it. Rating

Rating
web developer at WPLAB
Website development like the art

First, open your functions.php file and paste the following code in it: Rating

Rating
web developer at WPLAB
Website development like the art

First, open your functions.php file and paste the following code in it: /** * Filter HTML code and leave allowed/disallowed tags only * * @param string $text Input HTML code. * @param string $tags Filtered tags. * @param bool $invert Define whether should leave or remove tags. * @return string Filtered tags */ function theme_strip_tags_content($text, […]

Rating
web developer at WPLAB
Website development like the art

Paste the following code in your single.php file, within the loop. Edited the text on line 7 as desired. Rating

Rating
web developer at WPLAB
Website development like the art

Paste the following code in your single.php file, within the loop. Edited the text on line 7 as desired. <? $ageunix = get_the_time(‘U’); $days_old_in_seconds = ((time() – $ageunix)); $days_old = (($days_old_in_seconds/86400)); if ($days_old > 365) { echo ‘<div class=”disclaimer”>DISCLAIMER: this post is older than one year and may not be up to date with latest […]

Rating
web developer at WPLAB
Website development like the art

This code has to be pasted into your theme’s functions.php file. It can be customized to deal with custom post types, as shown on line 16 and after. Rating

Rating
web developer at WPLAB
Website development like the art

This code has to be pasted into your theme’s functions.php file. It can be customized to deal with custom post types, as shown on line 16 and after. add_filter( ‘default_content’, ‘pu_default_editor_content’ ); function pu_default_editor_content( $content ) { global $post_type; switch( $post_type ) { case ‘post’: $content = ‘Default content for blog posts.’; break; case ‘page’: […]

Rating
web developer at WPLAB
Website development like the art

First, place the code below into your theme’s functions.php file and don’t forget to save. Rating

Rating
web developer at WPLAB
Website development like the art

First, place the code below into your theme’s functions.php file and don’t forget to save. function wpb_user_registration_date($atts, $content = null ) { $userlogin = shortcode_atts( array( ‘user’ => FALSE, ), $atts ); $uname = $userlogin[‘user’]; if ($uname!== FALSE) { $user = get_user_by( ‘login’, $uname ); if ($user == false) { $message =’Sorry no such user […]

Rating
web developer at WPLAB
Website development like the art

Before pasting this code in your function.php file, edit line 11 and replace contact.php by the name of the page you want to disable the editor for. Rating

Rating
web developer at WPLAB
Website development like the art

Before pasting this code in your function.php file, edit line 11 and replace contact.php by the name of the page you want to disable the editor for. add_action( ‘admin_init’, ‘hide_editor’ ); function hide_editor() { // Get the Post ID. $post_id = $_GET[‘post’] ? $_GET[‘post’] : $_POST[‘post_ID’] ; if( !isset( $post_id ) ) return; // Get […]

Rating
web developer at WPLAB
Website development like the art

Simply paste this code where you want to display the active plugin list. Once saved, active plugins will be displayed. Rating

Rating
web developer at WPLAB
Website development like the art

Simply paste this code where you want to display the active plugin list. Once saved, active plugins will be displayed. function wpr_active_site_plugins() { $the_plugs = get_option(‘active_plugins’); foreach($the_plugs as $key => $value) { $string = explode(‘/’,$value); // Folder name will be displayed echo $string[0] .”n”; } } wpr_active_site_plugins(); Thanks to Snipplr for the tip!! The post […]

Rating
web developer at WPLAB
Website development like the art

Simply paste this code into your function.php file. Edit lines 5 and 6 at your convenience. Rating

Rating
web developer at WPLAB
Website development like the art

Simply paste this code into your function.php file. Edit lines 5 and 6 at your convenience. function wps_change_role_name() { global $wp_roles; if ( ! isset( $wp_roles ) ) $wp_roles = new WP_Roles(); $wp_roles->roles[‘contributor’][‘name’] = ‘Owner’; $wp_roles->role_names[‘contributor’] = ‘Owner’; } add_action(‘init’, ‘wps_change_role_name’); Thanks to Kevin Chard for the tip!! The post WordPress tip: Modify any role […]

Rating
web developer at WPLAB
Website development like the art

Simply paste the following code into your functions.php file: Rating

Rating
web developer at WPLAB
Website development like the art

Simply paste the following code into your functions.php file: function wps_login_error() { remove_action(‘login_head’, ‘wp_shake_js’, 12); } add_action(‘login_head’, ‘wps_login_error’); Credit: WordPress Support Forum The post How to remove login shake effect when error occurs appeared first on WPRecipes. Rating

Rating
web developer at WPLAB
Website development like the art

Just run the following query on your WordPress database to delete comments with nastyspamurl as url. Don’t forget to replace the table prefix wp_ if your database is using another prefix.And of course, create a backup of your database before running the query! Rating

Rating
web developer at WPLAB
Website development like the art

Just run the following query on your WordPress database to delete comments with nastyspamurl as url. Don’t forget to replace the table prefix wp_ if your database is using another prefix.And of course, create a backup of your database before running the query! DELETE from wp_comments WHERE comment_author_url LIKE “%nastyspamurl%” ; The post WordPress tip: […]

Rating