This is a solution you can provide to your client, using, as already said, a metabox.
You can copy/paste this in your functions.php
:
add_action( 'add_meta_boxes', 'bullet1545_add_custom_box' );
add_action( 'save_post', 'bullet1545_save_custom_meta_box' );
function bullet1545_add_custom_box( $post ) {
add_meta_box(
'Bullet Meta Box', // ID, should be a string
'Side List', // Meta Box Title
'bullet1545_custom_meta_box_content', // Your call back function, this is where your form field will go
'post', // The post type you want this to show up on, can be post, page, or custom post type
'normal', // The placement of your meta box, can be normal or side
'high' // The priority in which this will be displayed
);
}
function bullet1545_save_custom_meta_box(){
global $post;
// Get our form field
if( $_POST ) :
$bullet1545_custom_meta = esc_attr( $_POST['bullet1545-custom-meta-box'] );
// Update post meta
update_post_meta($post->ID, '_bullet1545_custom_meta', $bullet1545_custom_meta);
endif;
}
function bullet1545_custom_meta_box_content( $post ) {
// Get post meta value using the key from our save function in the second paramater.
$bullet1545_custom_meta = get_post_meta($post->ID, '_bullet1545_custom_meta', true);
echo '<label>Custom Meta Box:</label>
';
echo '<textarea name="bullet1545-custom-meta-box">'.$bullet1545_custom_meta.'</textarea>';
}
This will provide you a textarea in your post edit page.
Frontend
Now in your page.php, you could use that code :
<?php
$myBullets = get_post_meta(get_the_ID(), "_bullet1545_custom_meta", true); // retrieve the content of your metabox
echo '<ul>';
$textareaData = '<li>'.str_replace(array("\r","\n\n","\n"),array('',"\n","</li>\n<li>"),trim($myBullets,"\n\r")).'</li>'; // this line converts all the lines that are inside your textarea in li lines, removing empty lines
echo '</ul>';
?>
I hope that it is as clear as possible. With this solution, you don't have to maintain a plugin as well and the website owner won't have to use li tags.
_t5_extra_box
. – toscho♦ Jun 15 '13 at 10:52