After Installation of Visual Studio Code

Go to Preferences  → Settings and then paste code within {} brackets – “editor.minimap.enabled”: true, “files.autoSave”: “afterDelay”, “editor.autoIndent”: true, “editor.detectIndentation”: true, “editor.fontSize”: 14, “editor.wordWrap”: “on”,   Thanks!    

Change Custom Post Type Name Safely.

Just replace the second line’s post type names: global $wpdb; $old_post_types = array(‘old_type’ => ‘new_type’); foreach ($old_post_types as $old_type=>$type) { $wpdb->query( $wpdb->prepare( “UPDATE {$wpdb->posts} SET post_type = REPLACE(post_type, %s, %s) WHERE post_type LIKE %s”, $old_type, $type, $old_type ) ); $wpdb->query( $wpdb->prepare( “UPDATE {$wpdb->posts} SET guid = REPLACE(guid, %s, %s) WHERE guid LIKE %s”, “post_type={$old_type}”, “post_type={$type}”, …

Change Custom Post Type Name Safely. Read More »

WordPress Developers (Must Have) Plugins

The following plugins are very useful to WordPress developers. These may help you to make a standard and error-free theme and plugin. Developer. Debug Bar Query Monitor. Theme Check. User Switching. Regenerate Thumbnails. Log Deprecated Notice. RTL Tester, RTL Tester Mirror. Monster Widget. PHP Compatibility. SG Optimizer. Thank you!

Conditional Script Loading for Shotcode

In the functions.php file or in your plugin file write the code below – [php] /** * Check if it should load frontend scripts * * @return mixed|void */ private function should_load_scripts() { global $post; $load_scripts = is_active_widget( false, false, ‘wpl_logo_carousel_pro_widget_content’, true ) || ( is_a( $post, ‘WP_Post’ ) && has_shortcode( $post->post_content, ‘logo-carousel-pro’ ) ); …

Conditional Script Loading for Shotcode Read More »

Select Text on Click of a Div with CSS

[php] .selectable{ -webkit-touch-callout: all; /* iOS Safari */ -webkit-user-select: all; /* Safari */ -khtml-user-select: all; /* Konqueror HTML */ -moz-user-select: all; /* Firefox */ -ms-user-select: all; /* Internet Explorer/Edge */ user-select: all; /* Chrome and Opera */ } [/php]

How to Set a default Title for the custom post?

[php] function wpl_lc_add_custom_title( $data, $postarr ) { if($data[‘post_type’] == ‘wpl_lcp_shortcodes’) { if(empty($data[‘post_title’])) { $data[‘post_title’] = ‘Untitled Carousel’; } } return $data; } add_filter(‘wp_insert_post_data’, ‘wpl_lc_add_custom_title’, 10, 2 ); [/php] Now use the function [php] the_title(); [/php]

How to a Add Custom Meta Box for Multiple Post Type

[php] add_action( ‘add_meta_boxes’, ‘myplugin_add_custom_box’ ); function myplugin_add_custom_box() { add_meta_box( ‘myplugin_sectionid’, __( ‘My Post Section Title’, ‘myplugin_textdomain’ ), ‘myplugin_inner_custom_box’, ‘post’ ); add_meta_box( ‘myplugin_sectionid’, __( ‘My Post Section Title’, ‘myplugin_textdomain’ ), ‘myplugin_inner_custom_box’, ‘page’ ); } [/php] See: Stackexchange , Codex