Skip to content

Instantly share code, notes, and snippets.

@jmdodd
Created November 29, 2011 08:06
Show Gist options
  • Save jmdodd/1403950 to your computer and use it in GitHub Desktop.
Save jmdodd/1403950 to your computer and use it in GitHub Desktop.
Add post format support to Theme Hybrid via child theme
<?php
add_theme_support( 'post-formats', array( 'aside', 'chat', 'gallery', 'image', 'link', 'quote', 'status', 'video', 'audio' ) );
if ( ! function_exists( 'ucc_hybrid_entry_title' ) ) {
function ucc_hybrid_entry_title( $title ) {
global $post;
// Get rid of title on Status (tweets).
if ( has_post_format( 'status' ) ) {
$title = '';
}
// Reformat title on Link (bookmarks), using FeedWordPress functions. */
if ( has_post_format( 'link' ) ) {
if ( function_exists( 'is_syndicated' ) && is_syndicated() ) {
if ( is_front_page() && ! is_home() )
$title = the_title( '<h2 class="' . esc_attr( $post->post_type ) . '-title entry-title"><a href="' . esc_url( get_syndication_permalink() ) . '" title="' . the_title_attribute( 'echo=0' ) . '" rel="bookmark">', '</a></h2>', false );
elseif ( is_singular() )
$title = the_title( '<h1 class="' . esc_attr( $post->post_type ) . '-title entry-title"><a href="' . esc_url( get_syndication_permalink() ) . '" title="' . the_title_attribute( 'echo=0' ) . '" rel="bookmark">', '</a></h1>', false );
else
$title = the_title( '<h2 class="entry-title"><a href="' . esc_url( get_syndication_permalink() ) . '" title="' . the_title_attribute( 'echo=0' ) . '" rel="bookmark">', '</a></h2>', false );
}
}
return $title;
} }
add_filter( 'hybrid_entry_title', 'ucc_hybrid_entry_title' );
// Kill the byline on Status and Link.
if ( ! function_exists( 'ucc_hybrid_byline' ) ) {
function ucc_hybrid_byline( $byline ) {
if ( has_post_format( 'status' ) || has_post_format( 'link' ) ) {
$byline = '';
}
return $byline;
}
add_filter( 'hybrid_byline', 'ucc_hybrid_byline' );
// Adjust the meta on Status and Link to be more like delicious.com and twitter.com formats.
if ( ! function_exists( 'ucc_hybrid_entry_meta' ) ) {
function ucc_hybrid_entry_meta( $meta ) {
if ( 'post' == get_post_type() ) {
if ( has_post_format( 'link' ) )
$meta = '<p class="entry-meta">' . __( '[[entry-terms taxonomy="post_tag"]]' , hybrid_get_textdomain() ) . ' [[entry-edit-link]]</p>';
if ( has_post_format( 'status' ) )
// Use human time for the last 7 days.
if ( get_the_time( 'U' ) > ( time() - 60*60*24*7 ) )
$meta = '<p class="entry-meta">' . ozh_ta_in_reply_to_tweet( 'In reply to @%name%', false ) . ' ' . esc_html( human_time_diff( get_the_time( 'U' ), current_time('timestamp') ) ) . ' ago <a href="' . esc_url( ozh_ta_tweet_link( false ) ) . '" title="Original on Twitter">#</a> <a href="' . get_permalink() . '" title="Permalink" rel="bookmark">&#182;</a> [[entry-edit-link]]</p>';
else
$meta = '<p class="entry-meta">' . ozh_ta_in_reply_to_tweet( 'In reply to @%name%' , false ) . ' ' . get_the_time( 'g:ia M j Y' ) . ' <a href="' . esc_url( ozh_ta_tweet_link( false ) ) . '" title="Original on Twitter">#</a> <a href="' . get_permalink() . '" title="Permalink" rel="bookmark">&#182;</a> [[entry-edit-link]]</p>';
}
return $meta;
} }
add_filter( 'hybrid_entry_meta', 'ucc_hybrid_entry_meta' );
/*
Copyright 2011 Jennifer M. Dodd (email: jmdodd@gmail.com)
Released under the GPLv2 (or later).
*/
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment