Add Metabox in wordpress

There are several plugins available in wordpress which helps to add metabox .  It’s a ridiculous  task for worpress programmer to use them as already we have a simple action.

function adding_custom_boxes( $post_type, $post ) {
    add_meta_box( 
        'my-meta-box',
        __( 'My Meta Box' ),
        'render_my_meta_box',
        'post',     // here you can mention your post_type 
               for multiple post type pass array of them  
        'normal',
        'default'
    );
}

// action to add meta box
add_action('add_meta_boxes','adding_custom_boxes',10,2);

//function to add metabox html
function render_my_meta_box(){

}

Once you have metabox in backend, you will need to save metabox data for further retrieval.
You can save metabox data on post save and post update action.

function my_project_save_metabox_data( $post_id ) {
   /*
    *  here you can write your code to save metabox data
    *  you may get it with $_POST['field_name']
    *  you can save it in anywhere or postmeta.  
    */
}
add_action( 'save_post', 'my_project_save_metabox_data' );

Implode and Explode in PHP

We can store multiple value in single variable in two ways.
Either using Array, or comma separated values.

Comma separated: 
$name = 'Alex,Ana,BOB';
Array:  
$name =  array(
    [0] => 'BOB',
    [1] => 'Alex',
    [2] =>  'Ana'
);

To convert array to comma separated value and reverse
we required two function

implode : 
Syntax:  string implode ( string $glue , array $pieces )

$array = array(
    [0] => 'lastname',
    [1] => 'email',
    [2] => 'phone'
);
$comma_separated = implode(",", $array);

result :   will be "lastname,email,phone".
explode : 
Syntax:  array explode (string $delimiter,string $comma_string)

$input2 = "hello,there";
$result = var_dump( explode( ',', $input2 ) );

result : array( 
    [0] => 'hello',
    [1] => 'there'
);

Thanks ……!

Javascript recursion example

Everyone loves(or should i say ‘gets intimidated by’?) Recursion. But it can be confusing to begin with. So here’s an example of recursion ( in javascript ) to show how recursion can be used to solve real problems in real projects 😉 . The code below is an altered code from one of my projects. Although its in javascript, the basic principle is same and can be easily reproduced in any other language of your choice.

Hope it helps..

bbPress Tag Cloud Widget

A very small wordpress plugin. If you’ve been using bbPress plugin, you know that it provides a shortcode to display the topics-tag-cloud. I’ve wrapped that into a small widget, so one can just easily display the tag cloud wherever required with just drag-and-drop.

You can download the plugin form its github repository.
**Note: Github adds the word ‘-master’ into the plugin’s folder name, so uploading the zip file bbpress-tagcloud-widget-master.zip (downloaded from github) directly to install the plugin won’t work. So, just rename the zip file to bbpress-tagcloud-widget.zip.

That’s it here.