Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save celticwebdesign/79596feeeed34a6f8ed721681fb33b70 to your computer and use it in GitHub Desktop.
Save celticwebdesign/79596feeeed34a6f8ed721681fb33b70 to your computer and use it in GitHub Desktop.
add_meta_box('nme_pro_reviews_box', 'Property Reviews', 'nme_pro_reviews_box', 'property', 'normal', 'high');
function nme_pro_reviews_box() {
global $post;
$_nme_pro_review_1 = get_post_meta( $post->ID, '_nme_pro_review_1', true );
$_nme_pro_review_2 = get_post_meta( $post->ID, '_nme_pro_review_2', true );
$_nme_pro_review_3 = get_post_meta( $post->ID, '_nme_pro_review_3', true );
?>
<div class="nme_pro_reviews_section">
<p>
Review 1: <br />
<textarea style="width:100%; height: 80px;" name="_nme_pro_review_1"/><?php echo esc_attr($_nme_pro_review_1); ?></textarea>
</p>
<p>
Review 2: <br />
<textarea style="width:100%; height: 80px;" name="_nme_pro_review_2"/><?php echo esc_attr($_nme_pro_review_2); ?></textarea>
</p>
<p>
Review 3: <br />
<textarea style="width:100%; height: 80px;" name="_nme_pro_review_3"/><?php echo esc_attr($_nme_pro_review_3); ?></textarea>
</p>
</div>
<?php
}
add_action('save_post', 'wpt_save_pro_reviews', 1, 2);
function wpt_save_pro_reviews($post_id, $post) {
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
return $post->ID;
if (!current_user_can('edit_post', $post->ID))
return $post->ID;
update_post_meta( $post->ID, '_nme_pro_review_1', $_POST['_nme_pro_review_1'] );
update_post_meta( $post->ID, '_nme_pro_review_2', $_POST['_nme_pro_review_2'] );
update_post_meta( $post->ID, '_nme_pro_review_3', $_POST['_nme_pro_review_3'] );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment