Posts

Showing posts from January, 2016

How to add custom field in wordpress post taxonomy or in other custom taxonomy just like set feature image in taxonomy

Just copy and paste below code into your theme's functions.php file or into your custom plugin file and change taxonomy slug according to your requirement. <?php // Here i used custom taxonomy people_cat , You can also use post's default taxonomy like category , tag add_action( 'people_cat_add_form_fields', '_rj_add_category_fields' ); add_action( 'people_cat_edit_form_fields','_rj_edit_category_fields'); function _rj_add_category_fields($taxonomy) {  global $wpdb;   ?>   <div class="form-field">    <label><?php _e( 'Thumbnail', 'restlessdance' ); ?></label>    <div id="<?php echo $taxonomy; ?>_thumbnail" style="float: left; margin-right: 10px;"><img src="<?php echo esc_url( rj_placeholder_img_src() ); ?>" width="60px" height="60px" /></div>    <div style="line-height: 60px;">     <input ty...

How to add a custom sorting or order by option on category archive or product archive page in woocommerce wordpress

Just copy and paste below code into your theme's functions.php or into your custom plugin file and change option name and value according to your requirement. function rj_add_custom_postmeta_orderby( $sortby ) {     $sortby = array(); // do this for remove all default options        $sortby['grapes'] = __( 'Grapes', 'woocommerce' );     $sortby['main_region'] = __( 'Region', 'woocommerce' );     $sortby['wine_color'] = __( 'Colors', 'woocommerce' );     $sortby['class'] = __( 'Type', 'woocommerce' );     return $sortby; } add_filter( 'woocommerce_default_catalog_orderby_options', 'rj_add_custom_postmeta_orderby' ); add_filter( 'woocommerce_catalog_orderby', 'rj_add_custom_postmeta_orderby' ); function rj_get_catalog_ordering_args( $sort_args ) {             $orderby_value = isset( $_GET['orderby'] ) ? wc_clean( $_GET['orderby'] ) : appl...

Custom password reset functionality with form for wordpress

For add a custom password reset functionality in your wordpress site or blog just copy and paste below code into new template "password reset" or whatever you want to name it. and put into your theme's folder.. <?php /* Template Name: Password Reset Template */ global $wpdb, $user_ID; function tg_validate_url() {     global $post;     $page_url = esc_url(get_permalink( $post->ID ));     $urlget = strpos($page_url, "?");     if ($urlget === false) {         $concate = "?";     } else {         $concate = "&";     }     return $page_url.$concate; } if (!$user_ID) { //block logged in users     if(isset($_POST['action']) && $_POST['action']=='save_pw_reset')     {         if ( !wp_verify_nonce( $_POST['save_pwd_nonce'], "save_reset_password"))...

How to add a custom field in a post table quick edit box in wordpress

Below is working code for add a custom field into quick edit box // Below code will add a custom field. add_action( 'quick_edit_custom_box', 'rj_display_display_order_box_in_quick_edit', 10, 2 ); function rj_display_display_order_box_in_quick_edit( $column_name, $post_type ) {     if(!in_array( $post_type,array('people','watch-us') ))     {         return;     }     static $printNonce = TRUE;     if ( $printNonce ) {         $printNonce = FALSE;         wp_nonce_field( 'display_order_edit_field', 'display_order_edit_nonce' );     }     ?>     <fieldset class="inline-edit-col-right inline-edit-book">       <div class="inline-edit-col column-<?php echo $column_name; ?>">         <l...

How to create a custom wp_list_table and bulk action in wordpress

Below is a example of how to create a  custom wp_list_table and bulk actions.. Change below code according to your requirements. <?php global $wpdb; $table = $wpdb->prefix.'pp_buyer_package'; if($_REQUEST['action']=='delete' || $_REQUEST['action2']=='delete') {         if(isset($_REQUEST['pak_ids']) && $_REQUEST['_wpnonce']!='')     {         foreach($_REQUEST['pak_ids'] as $item)         {                $end_time = strtotime('now');             $cr_select = 'select * from '.$wpdb->prefix.'pp_package_buyer_relation where package_id = "'.$item.'" and end_time >= "'.$end_time.'"';             $cr_result =  $wpdb->get_row($cr_select);             if(count($cr...

How generate dynamic gradient effect in php

For generate dynamic gradient color in php just copy and paste below code into your file wherever you want to use.. <?php function random() {   return (float)rand()/(float)getrandmax(); } function getRandomArbitrary() {     $min = 0;     $max =0.5;     return random() * ($max - $min) + $min; }  $gradientSpeed = 0.002; function updateGradient() {     $min = 0; $max =0.5;     $colors =  array(   [floor(getRandomArbitrary() * 256) , floor(getRandomArbitrary() * 256),floor(getRandomArbitrary() * 256) ],   [floor(getRandomArbitrary() * 256) , floor(getRandomArbitrary() * 256) , floor(getRandomArbitrary() * 256) ],   [floor(getRandomArbitrary() * 256) , floor(getRandomArbitrary() * 256) , floor(getRandomArbitrary() * 256) ],   [floor(getRandomArbitrary() * 256) , floor(getRandomArbitrary() * 256), floor(getRandomArbitrary() * 256) ],   [floor(getRandomArbitrary() * 256) , ...