<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
>

<channel>
<title>milo Support forum for WordPress and BuddyPress themes Tag: hacks</title>
<link>http://forum.milo317.com/</link>
<description>WordPress tips, hacks and Security updates</description>
<language>en</language>
<pubDate>Fri, 18 May 2012 13:05:38 +0000</pubDate>

<item>
<title>milo on "WordPress Tips"</title>
<link>http://forum.milo317.com/topic/hacks/page/11#post-1539</link>
<pubDate>Sat, 05 Jun 2010 08:30:04 +0000</pubDate>
<dc:creator>milo</dc:creator>
<guid isPermaLink="false">1539@http://forum.milo317.com/</guid>
<description>&#60;p&#62;&#60;strong&#62;Comments A Comment Author Made&#60;/strong&#62;&#60;/p&#62;
&#60;p&#62;functions.php&#60;/p&#62;
&#60;p&#62;function commentCountAuthor(){&#60;br /&#62;
	$oneText = 'One comment';&#60;br /&#62;
	$moreText = '% comments';&#60;br /&#62;
	global $wpdb;&#60;br /&#62;
	$result = $wpdb-&#38;gt;get_var('&#60;br /&#62;
		SELECT&#60;br /&#62;
			COUNT(comment_ID)&#60;br /&#62;
		FROM&#60;br /&#62;
			'.$wpdb-&#38;gt;comments.'&#60;br /&#62;
		WHERE&#60;br /&#62;
			comment_author_email = &#34;'.get_comment_author_email().'&#34;'&#60;br /&#62;
	);&#60;br /&#62;
	if($result == 1):&#60;br /&#62;
		echo str_replace('%', $result, $oneText);&#60;br /&#62;
	elseif($result &#38;gt; 1):&#60;br /&#62;
		echo str_replace('%', $result, $moreText);&#60;br /&#62;
	endif;&#60;br /&#62;
}&#60;/p&#62;
&#60;p&#62;template&#60;/p&#62;
&#60;p&#62;commentCountAuthor();
&#60;/p&#62;</description>
</item>
<item>
<title>milo on "WordPress Tips"</title>
<link>http://forum.milo317.com/topic/hacks/page/10#post-1538</link>
<pubDate>Sat, 05 Jun 2010 08:28:41 +0000</pubDate>
<dc:creator>milo</dc:creator>
<guid isPermaLink="false">1538@http://forum.milo317.com/</guid>
<description>&#60;p&#62;&#60;strong&#62;Show Number of Retweets&#60;/strong&#62;&#60;/p&#62;
&#60;p&#62;Sign up with &#60;a href=&#34;http://www.backtype.com/&#34;&#62;Backtype&#60;/a&#62;  to use get an &#60;a href=&#34;http://www.backtype.com/developers&#34;&#62;API key&#60;/a&#62;.&#60;br /&#62;
Once you have that, put it in next to $key. &#60;/p&#62;
&#60;p&#62;&#38;lt;?php&#60;br /&#62;
$link = get_permalink($post-&#38;gt;ID);&#60;br /&#62;
$key = 'your key';&#60;br /&#62;
$url = &#34;http://api.backtype.com/tweetcount.xml?q=$link&#38;amp;key=$key&#34;;&#60;br /&#62;
$request = new WP_Http;&#60;br /&#62;
$result = $request-&#38;gt;request( $url );&#60;br /&#62;
echo &#34;&#38;lt;span class=\&#34;result\&#34;&#38;gt;&#34;.$result['body'].&#34;&#38;lt;/span&#38;gt; tweets&#34;;&#60;br /&#62;
?&#38;gt;
&#60;/p&#62;</description>
</item>
<item>
<title>milo on "WordPress Tips"</title>
<link>http://forum.milo317.com/topic/hacks/page/10#post-1536</link>
<pubDate>Tue, 01 Jun 2010 12:26:27 +0000</pubDate>
<dc:creator>milo</dc:creator>
<guid isPermaLink="false">1536@http://forum.milo317.com/</guid>
<description>&#60;p&#62;&#60;strong&#62;load plugins on pages &#60;/strong&#62;&#60;/p&#62;
&#60;p&#62;add_action( 'wp_print_scripts', 'my_deregister_javascript', 100 );&#60;br /&#62;
if ( !is_page('Events') ) {&#60;br /&#62;
wp_deregister_script( 'wpng-calendar' );&#60;br /&#62;
wp_deregister_script( 'date-js' );&#60;br /&#62;
wp_deregister_script( 'thickbox-js' );&#60;br /&#62;
wp_deregister_script( 'jquery-js' );&#60;br /&#62;
wp_deregister_script( 'wiky-js' );&#60;br /&#62;
}&#60;br /&#62;
}&#60;/p&#62;
&#60;p&#62;If you need to show the plugin on multiple pages, change the if  line to this:&#60;/p&#62;
&#60;p&#62;if ( !is_page(array(2,'events','about-us')) ) {
&#60;/p&#62;</description>
</item>
<item>
<title>milo on "WordPress Tips"</title>
<link>http://forum.milo317.com/topic/hacks/page/10#post-1535</link>
<pubDate>Tue, 01 Jun 2010 12:22:40 +0000</pubDate>
<dc:creator>milo</dc:creator>
<guid isPermaLink="false">1535@http://forum.milo317.com/</guid>
<description>&#60;p&#62;&#60;strong&#62;Extend the User Contact&#60;/strong&#62;&#60;/p&#62;
&#60;p&#62;functions&#60;/p&#62;
&#60;p&#62;function my_new_contactmethods( $contactmethods ) {&#60;br /&#62;
  // Add Twitter&#60;br /&#62;
  $contactmethods['twitter'] = 'Twitter';&#60;br /&#62;
  //add Facebook&#60;br /&#62;
  $contactmethods['facebook'] = 'Facebook';&#60;br /&#62;
  return $contactmethods;&#60;br /&#62;
}&#60;br /&#62;
add_filter('user_contactmethods','my_new_contactmethods',10,1);&#60;/p&#62;
&#60;p&#62;template&#60;/p&#62;
&#60;p&#62;&#38;lt;?php&#60;br /&#62;
$current_author = get_userdata(get_query_var('author'));&#60;br /&#62;
?&#38;gt;&#60;br /&#62;
&#38;lt; a href=&#34;&#38;lt;?php echo esc_url($current_author-&#38;gt;twitter);?&#38;gt;&#34; title=&#34;Twitter&#34;&#38;gt; Follow me on Twitter&#38;lt; /a&#38;gt;
&#60;/p&#62;</description>
</item>
<item>
<title>milo on "WordPress Tips"</title>
<link>http://forum.milo317.com/topic/hacks/page/10#post-1534</link>
<pubDate>Tue, 01 Jun 2010 12:19:56 +0000</pubDate>
<dc:creator>milo</dc:creator>
<guid isPermaLink="false">1534@http://forum.milo317.com/</guid>
<description>&#60;p&#62;&#60;strong&#62;Display an Author List &#60;/strong&#62;&#60;/p&#62;
&#60;p&#62;    function contributors() {&#60;br /&#62;
    global $wpdb;&#60;/p&#62;
&#60;p&#62;    $authors = $wpdb-&#38;gt;get_results(&#34;SELECT ID, user_nicename from $wpdb-&#38;gt;users ORDER BY display_name&#34;);&#60;/p&#62;
&#60;p&#62;    foreach($authors as $author) {&#60;br /&#62;
    echo &#34;&#38;lt; li&#38;gt;&#34;;&#60;br /&#62;
    echo &#34;&#38;lt; a href=\&#34;&#34;.get_bloginfo('url').&#34;/?author=&#34;;&#60;br /&#62;
    echo $author-&#38;gt;ID;&#60;br /&#62;
    echo &#34;\&#34;&#38;gt;&#34;;&#60;br /&#62;
    echo get_avatar($author-&#38;gt;ID);&#60;br /&#62;
    echo &#34;&#38;lt; /a&#38;gt;&#34;;&#60;br /&#62;
    echo '&#38;lt;div&#38;gt;';&#60;br /&#62;
    echo &#34;&#38;lt; a href=\&#34;&#34;.get_bloginfo('url').&#34;/?author=&#34;;&#60;br /&#62;
    echo $author-&#38;gt;ID;&#60;br /&#62;
    echo &#34;\&#34;&#38;gt;&#34;;&#60;br /&#62;
    the_author_meta('display_name', $author-&#38;gt;ID);&#60;br /&#62;
    echo &#34;&#38;lt;/ a&#38;gt;&#34;;&#60;br /&#62;
    echo &#34;&#38;lt;/div&#38;gt;&#34;;&#60;br /&#62;
    echo &#34;&#38;lt; /li&#38;gt;&#34;;&#60;br /&#62;
    }&#60;br /&#62;
    }
&#60;/p&#62;</description>
</item>
<item>
<title>milo on "WordPress Tips"</title>
<link>http://forum.milo317.com/topic/hacks/page/10#post-1533</link>
<pubDate>Tue, 01 Jun 2010 12:18:44 +0000</pubDate>
<dc:creator>milo</dc:creator>
<guid isPermaLink="false">1533@http://forum.milo317.com/</guid>
<description>&#60;p&#62;&#60;strong&#62;Custom Meta Box&#60;/strong&#62;&#60;/p&#62;
&#60;p&#62;/* Use the admin_menu action to define the custom boxes */&#60;br /&#62;
add_action('admin_menu', 'nyc_boroughs_add_custom_box');&#60;br /&#62;
/* Adds a custom section to the &#34;side&#34; of the post edit screen */&#60;br /&#62;
function nyc_boroughs_add_custom_box() {&#60;br /&#62;
     add_meta_box('nyc_boroughs', 'Applicable Borough', 'nyc_boroughs_custom_box', 'post', 'side', 'high');&#60;br /&#62;
}&#60;br /&#62;
/* prints the custom field in the new custom post section */&#60;br /&#62;
function nyc_boroughs_custom_box() {&#60;br /&#62;
     //get post meta value&#60;br /&#62;
     global $post;&#60;br /&#62;
     $custom = get_post_meta($post-&#38;gt;ID,'_nyc_borough',true);&#60;br /&#62;
     // use nonce for verification&#60;br /&#62;
     echo '&#38;lt;input type=&#34;hidden&#34; name=&#34;nyc_boroughs_noncename&#34; id=&#34;nyc_boroughs_noncename&#34; value=&#34;'.wp_create_nonce('nyc-boroughs').'&#34; /&#38;gt;';&#60;br /&#62;
     // The actual fields for data entry&#60;br /&#62;
     echo '&#38;lt;label for=&#34;nyc_borough&#34;&#38;gt;Borough&#38;lt;/label&#38;gt;';&#60;br /&#62;
     echo '&#38;lt;select name=&#34;nyc_borough&#34; id=&#34;nyc_borough&#34; size=&#34;1&#34;&#38;gt;';&#60;br /&#62;
      //lets create an array of boroughs to loop through&#60;br /&#62;
      $boroughs = array('Manhattan','Brooklyn','Queens','The Bronx','Staten Island');&#60;br /&#62;
      foreach ($boroughs as $borough) {&#60;br /&#62;
            echo '&#38;lt;option value=&#34;'.$borough.'&#34;';&#60;br /&#62;
            if ($custom == $borough) echo ' selected=&#34;selected&#34;';&#60;br /&#62;
            echo '&#38;gt;'.$borough.'&#38;lt;/option&#38;gt;';&#60;br /&#62;
      }&#60;br /&#62;
     echo &#34;&#38;lt;/select&#38;gt;&#34;;&#60;br /&#62;
}&#60;br /&#62;
/* use save_post action to handle data entered */&#60;br /&#62;
add_action('save_post', 'nyc_boroughs_save_postdata');&#60;br /&#62;
/* when the post is saved, save the custom data */&#60;br /&#62;
function nyc_boroughs_save_postdata($post_id) {&#60;br /&#62;
     // verify this with nonce because save_post can be triggered at other times&#60;br /&#62;
     if (!wp_verify_nonce($_POST['nyc_boroughs_noncename'], 'nyc-boroughs')) return $post_id;&#60;br /&#62;
     // do not save if this is an auto save routine&#60;br /&#62;
     if (defined('DOING_AUTOSAVE') &#38;#38;&#38;#38; DOING_AUTOSAVE) return $post_id;&#60;br /&#62;
     $nyc_borough = $_POST['nyc_borough'];&#60;br /&#62;
     update_post_meta($post_id, '_nyc_borough', $nyc_borough);&#60;br /&#62;
}
&#60;/p&#62;</description>
</item>
<item>
<title>milo on "WordPress Tips"</title>
<link>http://forum.milo317.com/topic/hacks/page/10#post-1532</link>
<pubDate>Tue, 01 Jun 2010 12:17:36 +0000</pubDate>
<dc:creator>milo</dc:creator>
<guid isPermaLink="false">1532@http://forum.milo317.com/</guid>
<description>&#60;p&#62;&#60;strong&#62;Your Own Logo&#60;/strong&#62;&#60;/p&#62;
&#60;p&#62;//hook the administrative header output&#60;br /&#62;
add_action('admin_head', 'my_custom_logo');&#60;/p&#62;
&#60;p&#62;function my_custom_logo() {&#60;br /&#62;
   echo '&#60;br /&#62;
      &#38;lt;style type=&#34;text/css&#34;&#38;gt;&#60;br /&#62;
         #header-logo { background-image: url('.get_bloginfo('template_directory').'/images/custom-logo.gif) !important; }&#60;br /&#62;
      &#38;lt;/style&#38;gt;&#60;br /&#62;
   ';&#60;br /&#62;
}
&#60;/p&#62;</description>
</item>
<item>
<title>milo on "WordPress Tips"</title>
<link>http://forum.milo317.com/topic/hacks/page/10#post-1531</link>
<pubDate>Tue, 01 Jun 2010 12:17:09 +0000</pubDate>
<dc:creator>milo</dc:creator>
<guid isPermaLink="false">1531@http://forum.milo317.com/</guid>
<description>&#60;p&#62;&#60;strong&#62;Customizing the Contextual Help Dropdown&#60;/strong&#62;&#60;/p&#62;
&#60;p&#62;//hook loading of new page and edit page screens&#60;br /&#62;
add_action('load-page-new.php','add_custom_help_page');&#60;br /&#62;
add_action('load-page.php','add_custom_help_page');&#60;br /&#62;
function add_custom_help_page() {&#60;br /&#62;
   //the contextual help filter&#60;br /&#62;
   add_filter('contextual_help','custom_page_help');&#60;br /&#62;
}&#60;br /&#62;
function custom_page_help($help) {&#60;br /&#62;
   //keep the existing help copy&#60;br /&#62;
   echo $help;&#60;br /&#62;
   //add some new copy&#60;br /&#62;
   echo &#34;&#38;lt;h5&#38;gt;Custom Features&#38;lt;/h5&#38;gt;&#34;;&#60;br /&#62;
   echo &#34;&#38;lt;p&#38;gt;Content placed above the more divider will appear in column 1. Content placed below the divider will appear in column 2.&#38;lt;/p&#38;gt;&#34;;&#60;br /&#62;
}
&#60;/p&#62;</description>
</item>
<item>
<title>milo on "WordPress Tips"</title>
<link>http://forum.milo317.com/topic/hacks/page/10#post-1530</link>
<pubDate>Tue, 01 Jun 2010 12:16:34 +0000</pubDate>
<dc:creator>milo</dc:creator>
<guid isPermaLink="false">1530@http://forum.milo317.com/</guid>
<description>&#60;p&#62;&#60;strong&#62;Customizing the Dashboard&#60;/strong&#62;&#60;/p&#62;
&#60;p&#62;add_action('wp_dashboard_setup', 'my_custom_dashboard_widgets');&#60;br /&#62;
function my_custom_dashboard_widgets() {&#60;br /&#62;
   global $wp_meta_boxes;&#60;br /&#62;
   unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']);&#60;br /&#62;
   unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']);&#60;br /&#62;
   unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']);&#60;br /&#62;
   wp_add_dashboard_widget('custom_help_widget', 'Help and Support', 'custom_dashboard_help');&#60;br /&#62;
}&#60;br /&#62;
function custom_dashboard_help() {&#60;br /&#62;
   echo '&#38;lt;p&#38;gt;Welcome to your custom theme! Need help? Contact the developer &#60;a href=&#34;http://url.com&#34;&#62;here&#60;/a&#62;.&#38;lt;/p&#38;gt;';&#60;br /&#62;
}
&#60;/p&#62;</description>
</item>
<item>
<title>milo on "WordPress Tips"</title>
<link>http://forum.milo317.com/topic/hacks/page/10#post-1529</link>
<pubDate>Tue, 01 Jun 2010 12:15:02 +0000</pubDate>
<dc:creator>milo</dc:creator>
<guid isPermaLink="false">1529@http://forum.milo317.com/</guid>
<description>&#60;p&#62;&#60;strong&#62;Additional Links to wp_list_pages&#60;/strong&#62;&#60;/p&#62;
&#60;p&#62;// include additional links&#60;br /&#62;
function add_bookmarks_to_menu($output) {&#60;br /&#62;
	$bookmarks = (array) get_bookmarks('hide_invisible=0&#38;#38;category_name=wp_list_pages');&#60;br /&#62;
	foreach ($bookmarks as $bookmark) {&#60;br /&#62;
		$output .= &#34;&#38;lt; li&#38;gt;&#38;lt; a href='{$bookmark-&#38;gt;link_url}'  title='{$bookmark-&#38;gt;link_name}'&#38;gt;{$bookmark-&#38;gt;link_name}&#38;lt; /a&#38;gt;&#38;lt;/ li&#38;gt;\n&#34;;&#60;br /&#62;
	}&#60;br /&#62;
	return $output;&#60;br /&#62;
}&#60;br /&#62;
add_filter('wp_list_pages', 'add_bookmarks_to_menu');
&#60;/p&#62;</description>
</item>
<item>
<title>milo on "WordPress Tips"</title>
<link>http://forum.milo317.com/topic/hacks/page/10#post-1528</link>
<pubDate>Tue, 01 Jun 2010 12:14:12 +0000</pubDate>
<dc:creator>milo</dc:creator>
<guid isPermaLink="false">1528@http://forum.milo317.com/</guid>
<description>&#60;p&#62;&#60;strong&#62;Private Page in Navigation Menu&#60;/strong&#62;&#60;/p&#62;
&#60;p&#62;&#38;lt; ul&#38;gt;&#60;br /&#62;
&#38;lt;?php // add a private page to your navigation menu&#60;br /&#62;
wp_list_pages('depth=1&#38;#38;title_li=0&#38;#38;sort_column=menu_order');&#60;br /&#62;
if(current_user_can('read_private_pages')) : ?&#38;gt;&#60;br /&#62;
	&#38;lt; li&#38;gt;&#38;lt; a href=&#34;&#38;lt;?php echo get_permalink(10); ?&#38;gt;&#34;&#38;gt;For Authors only&#38;lt; /a&#38;gt;&#38;lt; /li&#38;gt;&#60;br /&#62;
&#38;lt;?php endif; ?&#38;gt;&#60;br /&#62;
&#38;lt;/ ul&#38;gt;
&#60;/p&#62;</description>
</item>
<item>
<title>milo on "WordPress Tips"</title>
<link>http://forum.milo317.com/topic/hacks/page/10#post-1527</link>
<pubDate>Tue, 01 Jun 2010 12:12:59 +0000</pubDate>
<dc:creator>milo</dc:creator>
<guid isPermaLink="false">1527@http://forum.milo317.com/</guid>
<description>&#60;p&#62;&#60;strong&#62;Disable Widgets&#60;/strong&#62;&#60;/p&#62;
&#60;p&#62;functions&#60;/p&#62;
&#60;p&#62;&#38;lt;?php // disable all widgets&#60;br /&#62;
function disable_all_widgets($sidebars_widgets) {&#60;br /&#62;
	$sidebars_widgets = array(false);&#60;br /&#62;
	return $sidebars_widgets;&#60;br /&#62;
}&#60;br /&#62;
add_filter('sidebars_widgets', 'disable_all_widgets');&#60;br /&#62;
?&#38;gt;
&#60;/p&#62;</description>
</item>
<item>
<title>milo on "WordPress Tips"</title>
<link>http://forum.milo317.com/topic/hacks/page/10#post-1526</link>
<pubDate>Tue, 01 Jun 2010 12:11:57 +0000</pubDate>
<dc:creator>milo</dc:creator>
<guid isPermaLink="false">1526@http://forum.milo317.com/</guid>
<description>&#60;p&#62;&#60;strong&#62;Related Posts without a Plugin&#60;/strong&#62;&#60;/p&#62;
&#60;p&#62;&#38;lt;?php // related posts based on first tag of current post&#60;br /&#62;
$tags = wp_get_post_tags($post-&#38;gt;ID);&#60;br /&#62;
if ($tags) {&#60;br /&#62;
	echo '&#38;lt;h3&#38;gt;Related Posts&#38;lt;/h3&#38;gt;';&#60;br /&#62;
	$first_tag = $tags[0]-&#38;gt;term_id;&#60;br /&#62;
	$args = array(&#60;br /&#62;
			'tag__in' =&#38;gt; array($first_tag),&#60;br /&#62;
			'post__not_in' =&#38;gt; array($post-&#38;gt;ID),&#60;br /&#62;
			'showposts' =&#38;gt; 7, // how many posts?&#60;br /&#62;
			'caller_get_posts' =&#38;gt; 1&#60;br /&#62;
			);&#60;br /&#62;
	$my_query = new WP_Query($args);&#60;br /&#62;
  	if ($my_query-&#38;gt;have_posts()) { ?&#38;gt;&#60;br /&#62;
		&#38;lt; ul&#38;gt;&#60;br /&#62;
		&#38;lt;?php while ($my_query-&#38;gt;have_posts()) : $my_query-&#38;gt;the_post(); ?&#38;gt;&#60;br /&#62;
			&#38;lt; li&#38;gt;&#38;lt; a href=&#34;&#38;lt;?php the_permalink(); ?&#38;gt;&#34;&#38;gt;&#38;lt;?php the_title(); ?&#38;gt;&#38;lt; /a&#38;gt;&#38;lt; /li&#38;gt;&#60;br /&#62;
		&#38;lt;?php endwhile; ?&#38;gt;&#60;br /&#62;
		&#38;lt; /ul&#38;gt;&#60;br /&#62;
	&#38;lt;?php } ?&#38;gt;&#60;br /&#62;
&#38;lt;?php } ?&#38;gt;
&#60;/p&#62;</description>
</item>
<item>
<title>milo on "WordPress Tips"</title>
<link>http://forum.milo317.com/topic/hacks/page/10#post-1525</link>
<pubDate>Tue, 01 Jun 2010 12:10:46 +0000</pubDate>
<dc:creator>milo</dc:creator>
<guid isPermaLink="false">1525@http://forum.milo317.com/</guid>
<description>&#60;p&#62;&#60;strong&#62;Display Posts with Specific Custom Fields&#60;/strong&#62;&#60;/p&#62;
&#60;p&#62;&#38;lt;?php if (have_posts()) : while (have_posts()) : the_post(); ?&#38;gt;&#60;br /&#62;
&#38;lt;?php $custom_field = get_post_custom_values(&#34;name-of-custom-field&#34;); ?&#38;gt;&#60;br /&#62;
	&#38;lt;?php if (isset($custom_field[0])) { ?&#38;gt;&#60;br /&#62;
		&#38;lt;h1&#38;gt;&#38;lt; a href=&#34;&#38;lt;?php the_permalink(); ?&#38;gt;&#34;&#38;gt;&#38;lt;?php the_title(); ?&#38;gt;&#38;lt; /a&#38;gt;&#38;lt;/h1&#38;gt;&#60;br /&#62;
		&#38;lt;?php the_content(); ?&#38;gt;&#60;br /&#62;
	&#38;lt;?php } else { ?&#38;gt;&#60;br /&#62;
		&#38;lt;h2&#38;gt;&#38;lt; a href=&#34;&#38;lt;?php the_permalink(); ?&#38;gt;&#34;&#38;gt;&#38;lt;?php the_title(); ?&#38;gt;&#38;lt; /a&#38;gt;&#38;lt;/h2&#38;gt;&#60;br /&#62;
		&#38;lt;?php the_excerpt(); ?&#38;gt;&#60;br /&#62;
	&#38;lt;?php } ?&#38;gt;&#60;br /&#62;
&#38;lt;?php endwhile; endif; ?&#38;gt;
&#60;/p&#62;</description>
</item>
<item>
<title>milo on "WordPress Tips"</title>
<link>http://forum.milo317.com/topic/hacks/page/10#post-1524</link>
<pubDate>Tue, 01 Jun 2010 12:09:57 +0000</pubDate>
<dc:creator>milo</dc:creator>
<guid isPermaLink="false">1524@http://forum.milo317.com/</guid>
<description>&#60;p&#62;&#60;strong&#62;Three Columns&#60;/strong&#62;&#60;/p&#62;
&#60;p&#62;template&#60;/p&#62;
&#60;p&#62;&#38;lt;?php // multiple columns&#60;br /&#62;
$page_columns = explode(&#34;&#38;lt;--column--&#38;gt;&#34;, $post-&#38;gt;post_content);&#60;br /&#62;
echo $page_columns[0]; // before columns&#60;br /&#62;
echo '&#38;lt;div class=&#34;first column&#34;&#38;gt;'.$page_columns[1].'&#38;lt;/div&#38;gt;'; // first column&#60;br /&#62;
echo '&#38;lt;div class=&#34;second column&#34;&#38;gt;'.$page_columns[2].'&#38;lt;/div&#38;gt;'; // second column&#60;br /&#62;
echo '&#38;lt;div class=&#34;third column&#34;&#38;gt;'.$page_columns[3].'&#38;lt;/div&#38;gt;'; // third column&#60;br /&#62;
?&#38;gt;&#60;/p&#62;
&#60;p&#62;css&#60;/p&#62;
&#60;p&#62;/* column structure */&#60;br /&#62;
.column {&#60;br /&#62;
	margin-right: 10px;&#60;br /&#62;
	float: left;&#60;br /&#62;
	width: 33%;&#60;br /&#62;
	}&#60;br /&#62;
/* column styles */&#60;br /&#62;
column.first, column.second, column.third {}
&#60;/p&#62;</description>
</item>
<item>
<title>milo on "WordPress Tips"</title>
<link>http://forum.milo317.com/topic/hacks/page/10#post-1523</link>
<pubDate>Tue, 01 Jun 2010 12:08:41 +0000</pubDate>
<dc:creator>milo</dc:creator>
<guid isPermaLink="false">1523@http://forum.milo317.com/</guid>
<description>&#60;p&#62;&#60;strong&#62;Widgetizable Sidebars&#60;/strong&#62;&#60;/p&#62;
&#60;p&#62;&#38;lt;?php // multiple widgetizable sidebars&#60;br /&#62;
if (function_exists('register_sidebar')) {&#60;br /&#62;
	$sidebars = array('Home Sidebar', 'Post Sidebar', 'Page Sidebar');&#60;br /&#62;
	foreach($sidebars as $name) {&#60;br /&#62;
		register_sidebar(array('name'=&#38;gt; $name,&#60;br /&#62;
			'before_widget' =&#38;gt; '&#38;lt;div id=&#34;%1$s&#34; class=&#34;widget %2$s&#34;&#38;gt;',&#60;br /&#62;
			'after_widget' =&#38;gt; '&#38;lt;/div&#38;gt;',&#60;br /&#62;
			'before_title' =&#38;gt; '&#38;lt;h3 class=&#34;widgetTitle&#34;&#38;gt;',&#60;br /&#62;
			'after_title' =&#38;gt; '&#38;lt;/h3&#38;gt;',&#60;br /&#62;
		));&#60;br /&#62;
	}&#60;br /&#62;
}&#60;br /&#62;
?&#38;gt;
&#60;/p&#62;</description>
</item>
<item>
<title>milo on "WordPress Tips"</title>
<link>http://forum.milo317.com/topic/hacks/page/10#post-1522</link>
<pubDate>Tue, 01 Jun 2010 12:07:38 +0000</pubDate>
<dc:creator>milo</dc:creator>
<guid isPermaLink="false">1522@http://forum.milo317.com/</guid>
<description>&#60;p&#62;&#60;strong&#62;Most Commented Posts&#60;/strong&#62;&#60;/p&#62;
&#60;p&#62;&#38;lt; ul&#38;gt;&#60;br /&#62;
&#38;lt;?php&#60;br /&#62;
$result = $wpdb-&#38;gt;get_results(&#34;SELECT comment_count, ID, post_title FROM $wpdb-&#38;gt;posts ORDER BY comment_count DESC LIMIT 0 , 10&#34;); // NUMBER OF POSTS&#60;br /&#62;
foreach ($result as $topten) {&#60;br /&#62;
	$postid = $topten-&#38;gt;ID;&#60;br /&#62;
	$title = $topten-&#38;gt;post_title;&#60;br /&#62;
	$commentcount = $topten-&#38;gt;comment_count;&#60;br /&#62;
	if ($commentcount != 0) {&#60;br /&#62;
?&#38;gt;&#60;br /&#62;
&#38;lt; li&#38;gt;&#38;lt;  a href=&#34;&#38;lt;?php echo get_permalink($postid); ?&#38;gt;&#34;&#38;gt;&#38;lt;?php echo $title ?&#38;gt;&#38;lt; /a&#38;gt;&#38;lt;/ li&#38;gt;&#60;/p&#62;
&#60;p&#62;&#38;lt;?php } } ?&#38;gt;&#60;br /&#62;
&#38;lt; /ul&#38;gt;
&#60;/p&#62;</description>
</item>
<item>
<title>milo on "WordPress Tips"</title>
<link>http://forum.milo317.com/topic/hacks/page/10#post-1521</link>
<pubDate>Tue, 01 Jun 2010 12:06:46 +0000</pubDate>
<dc:creator>milo</dc:creator>
<guid isPermaLink="false">1521@http://forum.milo317.com/</guid>
<description>&#60;p&#62;&#60;strong&#62;Latest Comments&#60;/strong&#62;&#60;/p&#62;
&#60;p&#62;&#38;lt;?php global $wpdb;&#60;br /&#62;
$sql = &#34;SELECT DISTINCT ID, post_title, post_password, comment_ID,&#60;br /&#62;
comment_post_ID, comment_author, comment_date_gmt, comment_approved,&#60;br /&#62;
comment_type,comment_author_url,&#60;br /&#62;
SUBSTRING(comment_content,1,50) // NUMBER OF CHARACTERS&#60;br /&#62;
AS com_excerpt FROM $wpdb-&#38;gt;comments&#60;br /&#62;
LEFT OUTER JOIN $wpdb-&#38;gt;posts&#60;br /&#62;
ON ($wpdb-&#38;gt;comments.comment_post_ID = $wpdb-&#38;gt;posts.ID)&#60;br /&#62;
WHERE comment_approved = '1'&#60;br /&#62;
AND comment_type = ''&#60;br /&#62;
AND post_password = ''&#60;br /&#62;
ORDER BY comment_date_gmt&#60;br /&#62;
DESC LIMIT 5&#34;; // NUMBER OF COMMENTS&#60;br /&#62;
$comments = $wpdb-&#38;gt;get_results($sql);&#60;br /&#62;
$output   = $pre_HTML;&#60;br /&#62;
$output  .= &#34;\n&#38;lt; ul&#38;gt;&#34;;&#60;/p&#62;
&#60;p&#62;foreach ($comments as $comment) {&#60;br /&#62;
	$output .= &#34;\n&#38;lt; li&#38;gt;&#34;.&#34;&#38;lt; a href=\&#34;&#34; . get_permalink($comment-&#38;gt;ID) .&#60;br /&#62;
	&#34;#comment-&#34; . $comment-&#38;gt;comment_ID . &#34;\&#34; title=\&#34;on &#34; .&#60;br /&#62;
	$comment-&#38;gt;post_title . &#34;\&#34;&#38;gt;&#34; .strip_tags($comment-&#38;gt;comment_author)&#60;br /&#62;
	.&#34;:&#60;br /&#62;&#38;lt;div&#38;gt;&#34; . strip_tags($comment-&#38;gt;com_excerpt)&#60;br /&#62;
	.&#34;&#38;lt;/div&#38;gt;&#38;lt;/ a&#38;gt;&#38;lt;/ li&#38;gt;&#34;;&#60;br /&#62;
}&#60;br /&#62;
$output .= &#34;\n&#34;;&#60;br /&#62;
$output .= $post_HTML;&#60;br /&#62;
echo $output;&#60;br /&#62;
?&#38;gt;
&#60;/p&#62;</description>
</item>
<item>
<title>milo on "WordPress Tips"</title>
<link>http://forum.milo317.com/topic/hacks/page/10#post-1520</link>
<pubDate>Tue, 01 Jun 2010 12:05:37 +0000</pubDate>
<dc:creator>milo</dc:creator>
<guid isPermaLink="false">1520@http://forum.milo317.com/</guid>
<description>&#60;p&#62;&#60;strong&#62;Random Posts&#60;/strong&#62;&#60;/p&#62;
&#60;p&#62;functions&#60;/p&#62;
&#60;p&#62;function query_random_posts($query) {&#60;br /&#62;
	return query_posts($query . '&#38;#38;random=true');&#60;br /&#62;
}&#60;br /&#62;
class RandomPosts {&#60;br /&#62;
	function orderby($orderby) {&#60;br /&#62;
		if (get_query_var('random') == 'true')&#60;br /&#62;
			return &#34;RAND()&#34;;&#60;br /&#62;
		else&#60;br /&#62;
			return $orderby;&#60;br /&#62;
	}&#60;br /&#62;
	function register_query_var($vars) {&#60;br /&#62;
		$vars[] = 'random';&#60;br /&#62;
		return $vars;&#60;br /&#62;
	}&#60;br /&#62;
}&#60;br /&#62;
add_filter( 'posts_orderby', array('RandomPosts', 'orderby') );&#60;br /&#62;
add_filter( 'query_vars', array('RandomPosts', 'register_query_var') );&#60;/p&#62;
&#60;p&#62;template&#60;/p&#62;
&#60;p&#62;&#38;lt;?php query_posts('cat=11&#38;#38;showposts=11&#38;#38;random=true'); ?&#38;gt;
&#60;/p&#62;</description>
</item>
<item>
<title>milo on "WordPress Tips"</title>
<link>http://forum.milo317.com/topic/hacks/page/10#post-1519</link>
<pubDate>Tue, 01 Jun 2010 12:03:45 +0000</pubDate>
<dc:creator>milo</dc:creator>
<guid isPermaLink="false">1519@http://forum.milo317.com/</guid>
<description>&#60;p&#62;&#60;strong&#62;Automatically Remove Code Mistakes in Posts&#60;/strong&#62;&#60;/p&#62;
&#60;p&#62;functions&#60;/p&#62;
&#60;p&#62;function clean_bad_content($bPrint = false) {&#60;br /&#62;
	global $post;&#60;br /&#62;
	$szPostContent  = $post-&#38;gt;post_content;&#60;br /&#62;
	$szRemoveFilter = array(&#34;~&#38;lt;p[^&#38;gt;]*&#38;gt;\s?&#38;lt;/p&#38;gt;~&#34;, &#34;~&#38;lt;a[^&#38;gt;]*&#38;gt;\s?~&#34;, &#34;~&#38;lt;font[^&#38;gt;]*&#38;gt;~&#34;, &#34;~&#38;lt;\/font&#38;gt;~&#34;, &#34;~style\=\&#34;[^\&#34;]*\&#34;~&#34;, &#34;~&#38;lt;span[^&#38;gt;]*&#38;gt;\s?&#38;lt;/span&#38;gt;~&#34;);&#60;br /&#62;
	$szPostContent  = preg_replace($szRemoveFilter, '', $szPostContent);&#60;br /&#62;
	$szPostContent  = apply_filters('the_content', $szPostContent);&#60;br /&#62;
	if ($bPrint == false) return $szPostContent;&#60;br /&#62;
	else echo $szPostContent;&#60;br /&#62;
}&#60;/p&#62;
&#60;p&#62;template within loop&#60;/p&#62;
&#60;p&#62;&#38;lt;?php if (function_exists('clean_bad_content')) clean_bad_content(true); ?&#38;gt;
&#60;/p&#62;</description>
</item>
<item>
<title>milo on "WordPress Tips"</title>
<link>http://forum.milo317.com/topic/hacks/page/10#post-1518</link>
<pubDate>Tue, 01 Jun 2010 12:02:33 +0000</pubDate>
<dc:creator>milo</dc:creator>
<guid isPermaLink="false">1518@http://forum.milo317.com/</guid>
<description>&#60;p&#62;&#60;strong&#62;Limit Post Revisions&#60;/strong&#62;&#60;/p&#62;
&#60;p&#62;wp config file&#60;/p&#62;
&#60;p&#62;/* limit number of post revisions */&#60;br /&#62;
define('WP_POST_REVISIONS', 3);
&#60;/p&#62;</description>
</item>
<item>
<title>milo on "WordPress Tips"</title>
<link>http://forum.milo317.com/topic/hacks/page/10#post-1517</link>
<pubDate>Tue, 01 Jun 2010 12:01:53 +0000</pubDate>
<dc:creator>milo</dc:creator>
<guid isPermaLink="false">1517@http://forum.milo317.com/</guid>
<description>&#60;p&#62;&#60;strong&#62;Disable Post Revisions&#60;/strong&#62;&#60;/p&#62;
&#60;p&#62;wp config file&#60;/p&#62;
&#60;p&#62;/* disable post-revisioning nonsense */&#60;br /&#62;
define('WP_POST_REVISIONS', FALSE);
&#60;/p&#62;</description>
</item>
<item>
<title>milo on "WordPress Tips"</title>
<link>http://forum.milo317.com/topic/hacks/page/10#post-1516</link>
<pubDate>Tue, 01 Jun 2010 12:01:07 +0000</pubDate>
<dc:creator>milo</dc:creator>
<guid isPermaLink="false">1516@http://forum.milo317.com/</guid>
<description>&#60;p&#62;&#60;strong&#62;Display Private Posts to Logged-in Users&#60;/strong&#62;&#60;/p&#62;
&#60;p&#62;&#38;lt;?php if (have_posts()) : while (have_posts()) : the_post();&#60;br /&#62;
	$private = get_post_custom_values(&#34;private&#34;);&#60;br /&#62;
	if (isset($private[0]) &#38;#38;&#38;#38; $private == &#34;true&#34;) {&#60;br /&#62;
		if (is_user_logged_in()) {&#60;br /&#62;
			// Display private post to logged user&#60;br /&#62;
		}&#60;br /&#62;
	} else {&#60;br /&#62;
		// Display public post to everyone&#60;br /&#62;
	}&#60;br /&#62;
endwhile; endif; ?&#38;gt;
&#60;/p&#62;</description>
</item>
<item>
<title>milo on "WordPress Tips"</title>
<link>http://forum.milo317.com/topic/hacks/page/10#post-1515</link>
<pubDate>Tue, 01 Jun 2010 12:00:05 +0000</pubDate>
<dc:creator>milo</dc:creator>
<guid isPermaLink="false">1515@http://forum.milo317.com/</guid>
<description>&#60;p&#62;&#60;strong&#62;Display Total Number of Trackbacks and Pingbacks&#60;/strong&#62;&#60;/p&#62;
&#60;p&#62;functions&#60;/p&#62;
&#60;p&#62;function comment_count() {&#60;br /&#62;
	global $wpdb;&#60;br /&#62;
	$count = &#34;SELECT COUNT(*) FROM $wpdb-&#38;gt;comments WHERE comment_type = 'pingback' OR comment_type = 'trackback'&#34;;&#60;br /&#62;
	echo $wpdb-&#38;gt;get_var($count);&#60;br /&#62;
}
&#60;/p&#62;</description>
</item>

</channel>
</rss>

