Skip to content

Instantly share code, notes, and snippets.

View jmdodd's full-sized avatar

Jennifer M. Dodd jmdodd

View GitHub Profile
@jmdodd
jmdodd / gist:1695492
Created January 28, 2012 19:21
Add custom post types to the Loop (doing it wrong)
<?php
if ( ! function_exists( 'ucc_pre_get_posts_filter' ) ) {
function ucc_pre_get_posts_filter( $query ) {
if ( ! is_preview() && ! is_admin() && ! is_singular() && ! is_404() ) {
if ( $query->is_feed ) {
// As always, handle your feed post types here.
} else {
$my_post_type = get_query_var( 'post_type' );
if ( empty( $my_post_type ) ) {
@jmdodd
jmdodd / gist:1695468
Created January 28, 2012 19:14
Add custom post types to the Loop
<?php
if ( ! function_exists( 'ucc_add_cpts_to_pre_get_posts' ) ) {
function ucc_add_cpts_to_pre_get_posts( $query ) {
if ( $query->is_main_query() && ! is_post_type_archive() && ! is_singular() && ! is_404() ) {
$my_post_type = get_query_var( 'post_type' );
if ( empty( $my_post_type ) ) {
$args = array(
'exclude_from_search' => false,
'public' => true,
@jmdodd
jmdodd / gist:1551117
Created January 2, 2012 15:31
Add bbPress default styling support to a BuddyPress child theme
<?php
/*
A few words about the setup here: WordPress 3.3, BuddyPress 1.5.2, bbPress 2.0.2
The current WordPress theme is a child theme of bp-default, bp-child.
The following directories (and their contents) have been copied into the bp-child directory and are where edits are
performed:
/wp-content/plugins/bbpress/bbp-themes/bbp-twentyten/bbpress
/wp-content/plugins/bbpress/bbp-themes/bbp-twentyten/css
/wp-content/plugins/bbpress/bbp-themes/bbp-twentyten/js
@jmdodd
jmdodd / gist:1545420
Created December 31, 2011 21:36
Add post format to FeedWordPress syndicated posts
<?php
if ( ! function_exists( 'ucc_post_format_feedwordpress_syndicated_post' ) ) {
function ucc_post_format_feedwordpress_syndicated_post ( $data ) {
$feed = $data['meta']['syndication_feed'];
// Adjust stripos contents as needed.
if ( stripos( 'delicious.com', $feed ) !== false ) {
$data['tax_input']['post_format'] = 'post-format-link';
} elseif ( stripos( 'tumblr.com', $feed ) !== false ) {
@jmdodd
jmdodd / gist:1498397
Created December 19, 2011 18:56
List a post type object's terms and taxonomies
<?php
if ( ! function_exists( 'ucc_cpt_get_object_terms_list' ) ) {
function ucc_cpt_get_object_terms_list( $id = '', $echo = true ) {
global $post;
$id = absint( $id );
if ( empty( $id ) )
$id = $post->ID;
@jmdodd
jmdodd / gist:1497987
Created December 19, 2011 17:02
Filter FeedWordPress syndicated posts into custom post types
<?php
if ( ! function_exists( 'ucc_cpt_feedwordpress_syndicated_post' ) ) {
function ucc_cpt_feedwordpress_syndicated_post ( $data ) {
$feed = $data['meta']['syndication_feed'];
// Adjust stripos contents as needed.
if ( stripos( 'colourlovers.com/rss/lover/username/palettes/favorites', $feed ) !== false ) {
$data['post_type'] = 'colourlovers-palette';
} elseif ( stripos( 'colourlovers.com/rss/lover/username/colors/favorites', $feed ) !== false ) {
@jmdodd
jmdodd / gist:1488072
Created December 16, 2011 21:28
Add BuddyPress user notices Widget
<?php
// BuddyPress Sitewide Notice Widget is available from the WordPress.org Plugin Directory:
// http://wordpress.org/extend/plugins/buddypress-sitewide-notice-widget/
if ( ! class_exists( 'UCC_BP_Message_Notices_Widget' ) ) {
class UCC_BP_Message_Notices_Widget extends WP_Widget {
function __construct() {
parent::WP_Widget( 'ucc_bp_message_notices', 'BP Message Notices Widget', array( 'description' => 'The BuddyPress notice to all users' ) );
}
@jmdodd
jmdodd / gist:1486717
Created December 16, 2011 16:27
Remove posts with category (or categories) from BuddyPress Activity Stream
<?php
// Move the bp_blogs_record_post action to the later wp_insert_post, so that in_category will return the correct result.
if ( ! function_exists( 'ucc_wp_insert_post_bp_blogs_record_post' ) ) {
function ucc_wp_insert_post_bp_blogs_record_post() {
remove_action( 'save_post', 'bp_blogs_record_post', 10, 2 );
add_action( 'wp_insert_post', 'bp_blogs_record_post', 10, 2 );
} }
add_action( 'init', 'ucc_wp_insert_post_bp_blogs_record_post' );
@jmdodd
jmdodd / gist:1458883
Created December 11, 2011 06:35
Add taxonomy columns to admin Edit pages
<?php
if ( ! function_exists( 'ucc_taxonomy_columns' ) ) {
function ucc_taxonomy_columns( $columns ) {
if ( post_type_exists( $_REQUEST['post_type'] ) )
$post_type = $_REQUEST['post_type'];
else
$post_type = 'post';
$args = array(
@jmdodd
jmdodd / gist:1458820
Created December 11, 2011 06:19
Set custom post type and taxonomy terms with Ozh' Tweet Archiver
<?php
if ( ! function_exists( 'ucc_ozh_ta_insert_tweets_post' ) ) {
function ucc_ozh_ta_insert_tweets_post( $data ) {
// Replace values of [tax_input][category] and [post_type] with appropriate values.
$data['tax_input']['category'] = '1,2';
$data['post_type'] = 'tweet';
return $data;
} }
add_filter( 'ozh_ta_insert_tweets_post' , 'ucc_ozh_ta_insert_tweets_post' );