Skip to content

Instantly share code, notes, and snippets.

@milohuang
milohuang / gist:1342131
Created November 5, 2011 22:48
WordPress Permalinks Best Practice
http://themefortress.com/tips/5-things-after-installing-wordpress-8/
Permalinks Structure: /%category%/%postname%-%post_id%/
@milohuang
milohuang / gist:1342140
Created November 5, 2011 22:56
WordPress Permalinks Best Practice 2
http://themefortress.com/tips/5-things-after-installing-wordpress/8
Permalinks Structure: /%category%/%postname%/%post_id%/
@milohuang
milohuang / gist:1342145
Created November 5, 2011 23:04
Turn off WordPress Post Revision
define('WP_POST_REVISIONS', false ); // turn off post revision
@milohuang
milohuang / gist:1342156
Created November 5, 2011 23:10
Change WordPress Autosave Interval from 60 to 300 sec
define('AUTOSAVE_INTERVAL', 300 ); // change WP autosave interval from 60 seconds to 300 seconds
@milohuang
milohuang / gist:1342161
Created November 5, 2011 23:13
Delete all post revisions
DELETE FROM wp_posts WHERE post_type = "revision"; // where wp_posts is your WordPress table for posts
@milohuang
milohuang / gist:1342178
Created November 5, 2011 23:20
WordPress Delete Revisions 2
DELETE a,b,c
FROM wp_posts a
LEFT JOIN wp_term_relationships b ON (a.ID = b.object_id)
LEFT JOIN wp_postmeta c ON (a.ID = c.post_id)
WHERE a.post_type = 'revision'
-- If for some reason you associated a revision with
-- a tag or a category that was then removed when the
-- final post was published, you will have extra entries
-- in other tables such as terms.
@milohuang
milohuang / gist:1343251
Created November 6, 2011 18:04
bbPress2 BBCode
Bold: [b]bold[/b]
Italics: [i]italics[/i]
Underline: [u]underline[/u]
Strikeout:[s]striked this out[/s]
Color:
[color="red"]named red[/color]
[color=#ff0000]hex red again[/color]
Align:
@milohuang
milohuang / gist:1355876
Created November 10, 2011 19:28
WordPress Comment Template: Add Role Badge
<?php function reverie_comments($comment, $args, $depth) {
$GLOBALS['comment'] = $comment; ?>
<li <?php comment_class(); ?>>
<article id="comment-<?php comment_ID(); ?>">
<header class="comment-author vcard">
<?php echo get_avatar($comment,$size='40'); ?>
<?php printf(__('<cite class="fn">%s</cite>', 'reverie'), get_comment_author_link()) ?>
<?php
$commentator_id = get_comment(get_comment_ID())->user_id;
$commentator_info = get_userdata($commentator_id);
@milohuang
milohuang / gist:1360653
Created November 12, 2011 15:13
Create Custom Taxonomies
function people_init() {
// create a new taxonomy
register_taxonomy(
'people',
'post',
array(
'label' => __( 'People' ),
'sort' => true,
'args' => array( 'orderby' => 'term_order' ),
'rewrite' => array( 'slug' => 'person' )
@milohuang
milohuang / gist:1377784
Created November 18, 2011 21:17
MailChimp Signup Form
<!-- Begin MailChimp Signup Form -->
<div id="mc_embed_signup">
<form action="http://username.us2.list-manage2.com/" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank">
<h2>Subscribe to our mailing list</h2>
<div class="indicates-required"><span class="asterisk">*</span> indicates required</div>
<div class="mc-field-group">
<label for="mce-EMAIL">Email Address <span class="asterisk">*</span>
</label>
<input type="email" value="" name="EMAIL" class="required email" id="mce-EMAIL">
</div>