Codex tools: Log in / create account
Contents |
Here's how to use your own smilie images in WordPress via plugin or functions file, avoiding the need to modify core WordPress file.
/* Plugin Name: My Custom Smilies */ global $wpsmiliestrans; $wpsmiliestrans = array( ':mrgreen:' => 'icon_mrgreen.gif', ':neutral:' => 'icon_neutral.gif', ':twisted:' => 'icon_twisted.gif', ':arrow:' => 'icon_arrow.gif', ':shock:' => 'icon_eek.gif', ':smile:' => 'icon_smile.gif', );
Here's a neat little hack i figured out to add a category dropdown selection to QuickPress in WordPress 2.8.
function __quickpress_cats() {
if(!function_exists('is_admin') || !is_admin()) return;
// Parameters for wp_dropdown_categories
$args = array(
'order' => 'ASC',
'hierarchical' => 1,
'echo' => 0,
'name' => 'post_category[]',
'hide_empty' => 0
);
$select_cats = wp_dropdown_categories( $args );
echo '
</div>
<h4 id="category-label"><label for="post_category">Category</label></h4>
<div>
'.$select_cats.'
</div>
<div class="hide-if-no-js" style="margin: 0 0 .5em 5em;padding:8px 10px 5px 5px;">
';
return;
}
if(is_admin() || $query->is_admin) {
$here = array( basename($_SERVER['REQUEST_URI']), basename($_SERVER['SCRIPT_FILENAME']) );
if( ( $here[0] == ('index.php' || 'wp-admin')) && ( $here[1] == 'index.php') ) {
add_action('media_buttons','__quickpress_cats');
}
unset($here);
}
but there's a small bug. after you submit, you get a fresh, empty quickpress screen. except this time, there's no category picker. (johnywhy)
This a custom query to select all the tags associated with the current category (all posts for that category).
<?php
$varcat = get_query_var('cat');
$category_tags = $wpdb->get_results("
SELECT DISTINCT
terms2.term_id as tag_ID,
terms2.name as tag_name,
t2.count as posts_with_tag
FROM
$wpdb->posts as p1
LEFT JOIN $wpdb->term_relationships as r1 ON p1.ID = r1.object_ID
LEFT JOIN $wpdb->term_taxonomy as t1 ON r1.term_taxonomy_id = t1.term_taxonomy_id
LEFT JOIN $wpdb->terms as terms1 ON t1.term_id = terms1.term_id,
$wpdb->posts as p2
LEFT JOIN $wpdb->term_relationships as r2 ON p2.ID = r2.object_ID
LEFT JOIN $wpdb->term_taxonomy as t2 ON r2.term_taxonomy_id = t2.term_taxonomy_id
LEFT JOIN $wpdb->terms as terms2 ON t2.term_id = terms2.term_id
WHERE (
t1.taxonomy = 'category' AND
p1.post_status = 'publish' AND
terms1.term_id = '$varcat' AND
t2.taxonomy = 'post_tag' AND
p2.post_status = 'publish' AND
p1.ID = p2.ID
)
");
if($category_tags) {
echo '
<div class="static">
<h2>Category Tags</h2>
<div>
';
foreach($category_tags as $cat) {
echo '<a class="button rbutton" href="'.get_tag_link($cat->tag_ID).'">'.$cat->tag_name.'</a> ';
}
echo '
</div>
</div>
';
}
?>