Posts

Showing posts from February, 2016

How to add image option in nav menu in wordpress

Just copy and paste below code into your theme's functions.php or your's custom plugin file and change according to your need. Here is my code for add menu image with different hover image <?php class RJ_Menu_Image_Plugin {         public function __construct() {         add_action( 'init', array( $this, 'init' ) );         add_filter( 'manage_nav-menus_columns', array( $this, 'manage_nav_menu_image_column' ), 11 );         add_action( 'admin_head-nav-menus.php', array( $this, 'enqueue_js_for_nav_menu' ) );         add_filter( 'wp_setup_nav_menu_item', array( $this, 'wp_setup_nav_menu_item_menu_image' ) );         add_filter( 'walker_nav_menu_start_el', array( $this, 'walker_nav_menu_start_el' ), 10, 4 );         add_action( 'admin_action_delete-menu-item-image', array( $this, 'admin_action_delete' ) );         add_action( 'wp_ajax_set-menu-item-thumbnail', array( $t

How to execute wp_schedule_event event on custom time interval in wordpress

For add new time interval we need to first register it. // Here i register for every two minutes function add_every_two_minutes( $schedules ) {      $schedules [ 'every_two_minutes' ] = array (              'interval'   => 120,              'display'    => __( 'Every 2 Minutes' , 'textdomain' )      );             return $schedules ; } add_filter( 'cron_schedules' , 'add_every_two_minutes' ); Now we can use it as below wp_schedule_event( time(), 'every_ two _minutes' , 'cron_function_for_execute' );  

How to extend parent theme shortcode into child thme in wordpress or extend any plugins shortcode into theme file

Just copy and paste below code into your theme's functions.php file or into your custom plugin file and change according to your need. // Here i have no_icon_text shortcode into my parent theme. add_action('init', 'remove_parent_no_icon_text'); function remove_parent_no_icon_text() { // i remove shortcode of parent theme remove_shortcode( 'no_icon_text' ); // Initialize child theme shortcode for changes into render add_shortcode( 'no_icon_text', 'rj_extend_no_icon_text' ); } function rj_extend_no_icon_text() { // shortcode render here }