Posts

Showing posts with the label WordPress

How to clear the cache of client browsers?

Image
Hello friends today we will learn how to clear the cache client browsers. This technique is very simple. Just add a version parameter to the URL string which is either a random string or a random number. If you change your sites CSS and upload on the server you will get old result only. For solve this problem, simply add ?ver=1.1 to the CSS import at the head of the file. So the browser teat as a different file. Example: <link href="css/style.css" rel="stylesheet" type="text/css" /> Becomes <link href="css/style.css?ver=1.1" rel="stylesheet" type="text/css" /> Same you can apply for JavaScript files.

WP Migrate DB

Image
Friends used WP Migrate DB plugin. Which is very easy to migrate your database from one server to another without any loss information. Trust me I have used this plugin in many website. WP Migrate DB exports your database as a MySQL data dump (much like phpMyAdmin), does a find and replace on URLs and file paths, handles serialized data, then allows you to save it to your computer as an SQL file. To complete the migration, you need to use a database management tool (e.g. phpMyAdmin) to import the SQL file to your database, replacing your existing database. It is perfect for developers who need to migrate fresh data from the production site to their local install, or migrate their locally developed site to a staging or production server. Check Link Click Here

Random post generate in wordpress

You have to first know default args of wordpress <?php $args  = array(      'numberposts'      =>  5 ,      'offset'           =>  0 ,      'category'         =>  ,      'orderby'          =>  'post_date' ,      'order'            =>  'DESC' ,      'include'          =>  ,      'exclude'          =>  ,      'meta_key'         =>  ,      'meta_value'       =>  ,      'post_type'        =>  'post' ,      'post_mime_type'   =>  ,      'post_parent'      =>  ,      'post_status'      =>  'publish' ,      'suppress_filters'  =>  true  );  ?> Use get_posts function and pass all the args which you have need. Example below Call function  <?php wp_get_theme_post(); ?>     in your templates Create function in function.php file   In if ( ! function_exists ( 'wp_get_theme_post'

How to register sidebar in widget?

Add following code in your wordpress function.php file if ( function_exists('register_sidebar') ) {     register_sidebar(array(         'name'=>'Sidebar1',         'before_widget' => '<li id="%1$s" class="widget %2$s">',         'after_widget' => '</li>',         'before_title' => '<h2 class="widgettitle">',         'after_title' => '</h2>',     )); }

How to create shortcode in wordpress?

Step 1.  Create PHP File shortcode.php. Insert Following code in file <?php add_shortcode('video_emb', 'video_emb'); function video_emb($atts){     $atts = shortcode_atts(array(         'src'=>'',         'height'=>'388',         'width'=>'600',         'title'=>''     ), $atts);        echo '         <div id="tutorial_image">             <iframe width="' . $atts['width'] . '" height="' . $atts['height'] . '" src="' . $atts['src'] . '" frameborder="0" allowfullscreen></iframe>             <h4>' . $atts['title'] . '</h4>         </div>     '; } ?> Step 2. Include this file in function.php on top. Try out shortcode in POST. [video_emb src="c:\fdsf.avi"]

Crash Course Wordpress Short Code Develoment

Image

Customize wordpress register form wp_register()

<div>             <h3>Register for this site!</h3>             <p>Sign up now for the good stuff.</p>             <form method="post" action="<?php echo site_url('wp-login.php?action=register', 'login_post') ?>" class="wp-user-form">                 <div class="username">                     <label for="user_login"><?php _e('Username'); ?>: </label>                     <input type="text" name="user_login" value="<?php echo esc_attr(stripslashes($user_login)); ?>" size="20" id="user_login" tabindex="101" />                 </div>                                <div class="password">                     <label for="user_email"><?php _e('Your Email'); ?>: </label>                     <input type="text"

How to Create Top Level Menu in wordpress?

Setting is a top-level menu. A top-level menu is common practice for any plugin that needs multiple option pages. To register a top - level menu, you use the add_menu_page() function. < ?php       add_menu_page( page_title, menu_title, capability, menu_slug, function, icon_url, position ); ? > The add_menu_page() function accepts the following parameters: page_title — The title of the page as shown in the <title> tags menu_title — The name of your menu displayed on the dashboard capability — Minimum capability required to view the menu menu_slug — Slug name to refer to the menu; should be a unique name function : Function to be called to display the page content for the item icon_url — URL to a custom image to use as the Menu icon position — Location in the menu order where it should appear < ?php add_action( ‘admin_menu’, ‘menuexample_create_menu’ ); function menuexample_create_menu() { //create custom top-level menu add_menu_page( ‘My Plugin Page’,

Simple Plugin in WordPress

Following is a simple example of word press development plugin. Any further query comment it. ........... <?php Plugin Name : Simple plugin Plugin URI : http://www.wordpress.org/ Description : Simple plugin  WordPress Plugin Example Author :  Ikhlaque Version : 0.01 Author URI : http://www.webin2.com/ function hello($content){  print $content . "Hello Ikhlaque"; } add_filter('the_content','hello'); ............