Posts Tagged "code"

How to disable posts auto save in WordPress?

WordPress have a very useful function that auto-saves your posts while you’re typing them in the dashboard. Though, if for some reason you’d like to disable this function, it is very easy to do. Just read on! To disable WordPress autosaving function, simply open your functions.php file and paste the following function: function disableAutoSave(){ wp_deregister_script(‘autosave’); } add_action(‘wp_print_scripts’, ‘disableAutoSave’); That’s all. Once you saved the file, WordPress will never autosave a post. To enable autosaving again, simply delete this code. Shashi…

Read More

How to validate ‘target=_blank’ in anchor tag with W3C Compatibility

While the apply ‘_blank’ value to a native link’s attribute ‘target’ that will give you not validated for W3C, the solution is to handle the click on the link and open it in a new window. Please note this alternative methods are absolutely SEO friendly and W3C valid. The code for the solution is: <script type=”text/javascript”> $(document).ready(function(){ $(‘A[rel=”_blank”]’).click(function(){ window.open($(this).attr(‘href’)); return false; }); }); </script> <a href=”http://www.shashidharkumar.com/shashidharkumar/index.html” rev=”solution-02″ rel=”_blank”>Shashidhar Kumar</a> Shashi Dhar KumarShashi Dhar Kumar Experience in Web/software development including client…

Read More

How to add custom post type in wordpress

Open “function.php” add the following code to add new custom post type : <?php add_action(‘init’, ‘featured_post_register’); function featured_post_register() { $labels = array( ‘name’ => _x(‘Featured Posts’, ‘post type general name’), ‘singular_name’ => _x(‘Featured Posts’, ‘post type singular name’), ‘add_new’ => _x(‘Add New’, ‘featured posts’), ‘add_new_item’ => __(‘Add New Featured Posts’), ‘edit_item’ => __(‘Edit Featured Posts’), ‘new_item’ => __(‘New Featured Posts’), ‘view_item’ => __(‘View Featured Posts’), ‘parent_item_colon’ => ” ); $args = array( ‘labels’ => $labels, ‘public’ => true, ‘publicly_queryable’ =>…

Read More

301 redirect with htaccess

How to redirect web based page with .htaccess Following are the code to paste (be careful to write on .htaccess it can be messed up whole website if anything goes wrong) into .htaccess file 301 redirection for any domain : RewriteEngine On RewriteCond %{HTTP_HOST} !^www.olddomain.com RewriteRule ^(.*)$ http://www.newdomain.com [R=301,L] newdomainRewriteRule ^$ http://www.newdomain.com [R=301,L] RewriteRule ^index.htm$ http://www.newdomain.com [R=301,L] RewriteRule ^index.php$ http://www.newdomain.com [R=301,L] RewriteRule ^index.html$ http://www.newdomain.com [R=301,L] RewriteRule ^index.shtml$ http://www.newdomain.com [R=301,L] RewriteRule ^index.asp$ http://www.newdomain.com [R=301,L] RewriteRule ^default.asp$ http://www.newdomain.com [R=301,L] RewriteRule ^index.aspx$ http://www.newdomain.com…

Read More