. You may want to add CSS to style the list.
If you want other html, you can try things like the following:
before is the text put before the list of tags
after is the text appended at the end
separator is the text put between two tags in the list
For example:
", "
", "
"); ?>
SETTINGS
========
If you want the plugin to try and use a comma-separated "keywords" post_meta field if there is no space-separated "to2blogs_tags" field available, replace "true" below by "false": */
$t2b_strict=true;
/*
CREDITS
=======
This plugin is based on Stephanie Booth (http://climbtothestars.org/) code.
*/
// retrieve tag values from post_meta
function get_t2b_tags($separator=" ", $meta_field)
{
$tags = get_post_custom_values($meta_field);
if(!empty($tags[0]))
{
$tags_array = explode($separator, $tags[0]);
}
return($tags_array); // return an array of tags
}
// prepare formatted tag list from $tags_array
function output_t2b_tags($tags_array, $before, $after, $separator)
{
if(!empty($tags_array))
{
$tags_list=$before; // HTML to display before the list of tags
foreach($tags_array as $tag) // go through all tags for the post
{
$display_tag = urldecode($tag);
$display_tag = str_replace("+", " ", $display_tag);
$tag_link='' . $display_tag . '' . $separator;
$tags_list.=$tag_link; // stick it on the end of the growing list
}
$chomp = 0 - strlen($separator);
$tags_list=substr($tags_list, 0, $chomp);
$tags_list.=$after;
}
return($tags_list);
}
// prepare the formatted list of tags -- this is what you mess with if your custom field values aren't formatted like described in the instructions
function get_t2b_tags_list($before, $after, $separator)
{
global $t2b_strict;
$t2b_tags=get_t2b_tags(' ', 'to2blogs_tags');
$label="Tags";
if(empty($t2b_tags)&&!$t2b_strict)
{
$t2b_tags=get_t2b_tags(', ', 'keywords');
$label="Keywords";
}
$t2b_tags_list=output_t2b_tags($t2b_tags, $before, $after, $separator);
return($t2b_tags_list);
}
// stick the list of tags at the end of the_content if we're in a feed
function append_to2blogs_tags($content)
{
global $feed;
if (!empty($feed)&&!is_single())
{
$tags_list=get_t2b_tags_list('
To2blogs: ', '
', ', ');
$content.=$tags_list;
}
return $content;
}
// output textarea to easily add tags in admin menu (addition to the post form)
function add_t2b_tags_textinput() {
global $post;
$tags = get_post_meta($post->ID, 'to2blogs_tags', true);
echo '';
}
// general custom field update function
function t2b_update_tags($id)
{
$setting = $_POST['to2blogs_tags'];
$meta_exists=update_post_meta($id, 'to2blogs_tags', $setting);
if(!$meta_exists)
{
add_post_meta($id, 'to2blogs_tags', $setting);
}
}
add_action('simple_edit_form', 'add_t2b_tags_textinput');
add_action('edit_form_advanced', 'add_t2b_tags_textinput');
add_action('edit_page_form', 'add_t2b_tags_textinput');
add_action('edit_post', 't2b_update_tags');
add_action('publish_post', 't2b_update_tags');
add_action('save_post', 't2b_update_tags');
add_filter('the_content', 'append_to2blogs_tags');
// TEMPLATE FUNCTION
function the_to2blogs_tags($before = '