WordPress Tagging
I just upgraded to WordPress 2.3 which supports tagging natively. There’s a new spot under the Edit window where you can enter tags. I’m lazy though so I’d like it if it could present me with a list of my tags so I could click and add them automatically… I just modified the code a little bit for one file in Wordpress and it appears to work… here’s what I did.
In the file wp-admin/edit-form-advanced.php, insert the following:
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | <script type="text/javascript">
function setTag(text)
{
var curvalue = document.getElementById('tags-input').value;
if (curvalue == "")
{
document.getElementById('tags-input').value = text;
}
else
{
document.getElementById('tags-input').value = curvalue + ", " + text;
}
}
</script>
<?php
$output = "<legend>";
$tags = (array) get_terms('post_tag', $args);
foreach ($tags as $tag)
{
$output .= "<a href=\"#\" onClick=\"setTag('".$tag->name."')\">".$tag->name."</a>,";
}
$output = substr($output, 0, strlen($output) - 1);
$output .= "</legend>";
echo $output;
?> |
Andrew Flanagan on October 5th 2007 in Actual Events, Geekiness, MetaData






