Posts

Showing posts with the label custom-field

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 column in custom post type list in admin side wordpress

For add a custom column in admin side list for custom post type or any post type just copy and paste below code into your theme's functions.php function rj_display_rank_column_data( $column, $post_id ) {     global $wpdb;     switch ( $column ) {         case 'rank' :                     $rank = get_post_meta($post_id,'optimus_rank_field',true);                if($rank!='9999' && $rank!='')                {                 echo $rank;                }else               ...

How to add a custom field in custom taxonomy or how to add a image field for custom taxonomy like woocommerce produc_cat in wordpress

How to add a custom field in custom taxonomy or how to add a image field for custom taxonomy like woocommerce produc_cat in wordpress For add a custom field in custom taxonomy or add a image field for custom taxonomy just copy below code and add it into your theme's functions.php file and change a taxonomy slug as per your need. // actual action for add add_action( '{custom-taxonomy-slug}_add_form_fields', 'rj_video_categories_add_category_fields' ); //actual action for edit  add_action( '{custom-taxonomy-slug}_edit_form_fields','rj_video_categories_edit_category_fields'  ); add_action( 'video-categories_add_form_fields', 'rj_video_categories_add_category_fields' ); add_action( 'video-categories_edit_form_fields','rj_video_categories_edit_category_fields'  ); function rj_video_categories_add_category_fields() { global $wpdb; ?> <div class="form-field"> <label><?php _e...

How to add a custom field or meta box in wordpress post or any custom post type in admin side

For add a meta box or custom filed to your any post type  just copy below code and add it into your theme's functions.php file and change according to you need. function rj_feature_video_add_meta_box() {     $screens = array( 'firework-video' );   // change post type slugs     foreach ( $screens as $screen ) {         add_meta_box(             'feature_video_fireworks',             __( 'Feature Video', 'flatsome' ),             'rj_feature_video_fireworks_meta_box_callback',             $screen         );     } } add_action( 'add_meta_boxes', 'rj_feature_video_add_meta_box' ); function rj_feature_video_fireworks_meta_box_callback( $post ) {     wp_nonce_field( 'rj_feature_v...

How to add a custom taxonomy field in woocommerce product category or any other custom taxonomy in wordpress

For add a custom taxonomy  field in product category or any other custom taxonomy Add below code in functions.php file of your theme. function product_cat_add_video_field_rj() {         ?>     <div class="form-field">         <label for="term_meta[video_link]"><?php _e( 'Video Link', 'flatsome' ); ?></label>         <input type="text" name="term_meta[video_link]" id="term_meta[video_link]" value="">         <p class="description"><?php _e( 'Enter a Video Link','flatsome' ); ?></p>     </div> <?php } function product_cat_edit_video_field_rj($term) {     $t_id = $term->term_id;     $term_meta = get_option( "taxonomy_$t_id" ); ?>     <tr class="form-field">     <th scope="row" valign="top"><labe...