Applying the Category to Attachments in WordPress

You can assign category to media in wordpress using following php code.

function ptt_add_categories_to_attachments() {
	register_taxonomy_for_object_type( 'category', 'attachment' );
}
add_action( 'init' , 'ptt_add_categories_to_attachments' );

Continue reading “Applying the Category to Attachments in WordPress”

Advertisements

Use WordPress default jQuery UI “datepicker” in your theme

First write following code in template file. These code will include js and datepicker class in the template.

wp_enqueue_script('jquery');
wp_enqueue_script('jquery-ui-core');
wp_enqueue_script('jquery-ui-datepicker');
wp_enqueue_style('jquery-ui-css', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css');

Continue reading “Use WordPress default jQuery UI “datepicker” in your theme”

Common steps to write a WordPress Plugin

  1. Create a php file which name same as plugin name.
  2.  Add Standard Plugin header information in top of the file. This header information help wordpress to active ,load plugin and run its functionality. Without header information your plugin will never run and work in WordPress.
  3.  Write plugin code logic in file. Add plugin code for action and filters.
  4. Add admin panel for your plugin. this step is not neccessory but useful when you have plugin setting and want to save and retrive plugin settings from database.
  5. Plugin is ready to use in WordPress.