Created
February 2, 2015 21:44
-
-
Save mrbobbybryant/f5df7d6e006db3ebe6de to your computer and use it in GitHub Desktop.
Metabox Callback Function for How to build Plugin series
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* This is the entire callback function for the metabox. You can copy the whole thing or just the fields. | |
*/ | |
function dwwp_meta_callback() { | |
?> | |
<div> | |
<div class="meta-row"> | |
<div class="meta-th"> | |
<label for="job-id" class="dwwp-row-title">Job ID</label> | |
</div> | |
<div class="meta-td"> | |
<input type="text" name="job-id" id="job-id" value=""/> | |
</div> | |
</div> | |
<div class="meta-row"> | |
<div class="meta-th"> | |
<label for="date_listed" class="dwwp-row-title">Date Listed</label> | |
</div> | |
<div class="meta-td"> | |
<input type="text" name="date_listed" id="date_listed" value=""/> | |
</div> | |
</div> | |
<div class="meta-row"> | |
<div class="meta-th"> | |
<label for="application_deadline" class="dwwp-row-title">Application Deadline</label> | |
</div> | |
<div class="meta-td"> | |
<input type="text" name="application_deadline" id="application_deadline" value=""/> | |
</div> | |
</div> | |
<div class="meta"> | |
<div class="meta-th"> | |
<span>Principle Duties</span> | |
</div> | |
</div> | |
<div class="meta-editor"></div> | |
<?php | |
$content = get_post_meta( $post->ID, 'principle_duties', true ); | |
$editor = 'principle_duties'; | |
$settings = array( | |
'textarea_rows' => 8, | |
'media_buttons' => false, | |
); | |
wp_editor( $content, $editor, $settings); | |
?> | |
</div> | |
<div class="meta-row"> | |
<div class="meta-th"> | |
<label for="minimum-requirements" class="wpdt-row-title"><?php _e( 'Minimum Requirements', 'hrm-textdomain' )?></label> | |
</div> | |
<div class="meta-td"> | |
<textarea name="minimum-requirements" class ="hrm-textarea" id="minimum-requirements"><?php if ( isset ( $hrm_stored_meta['minimum-requirements'] ) ) echo esc_attr( $hrm_stored_meta['minimum-requirements'][0] ); ?></textarea> | |
</div> | |
</div> | |
<div class="meta-row"> | |
<div class="meta-th"> | |
<label for="preferred-requirements" class="wpdt-row-title"><?php _e( 'Preferred Requirements', 'hrm-textdomain' )?></label> | |
</div> | |
<div class="meta-td"> | |
<textarea name="preferred-requirements" class ="hrm-textarea" id="preferred-requirements"><?php if ( isset ( $hrm_stored_meta['preferred-requirements'] ) ) echo esc_attr( $hrm_stored_meta['preferred-requirements'][0] ); ?></textarea> | |
</div> | |
</div> | |
<div class="meta-row"> | |
<div class="meta-th"> | |
<label for="relocation-assistance" class="prfx-row-title"><?php _e( 'Relocation Assistance', 'hrm-textdomain' )?></label> | |
</div> | |
<div class="meta-td"> | |
<select name="relocation-assistance" id="relocation-assistance"> | |
<option value="select-yes">Yes</option>'; | |
<option value="select-no">No</option>'; | |
</select> | |
</div> | |
</div> | |
<?php | |
} |
Thank you GilLopezMX!
For the get_the_ID() info instead of $post->ID
Thank you!
$post->ID will only work if you use globally, so line 42 and 43 will read like:
global $post;
$content = get_post_meta( $post->ID, 'principle_duties', true );
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I was having the same issues at the end I got the follow code working as the video. By the way they are great
}