Last active
August 29, 2015 14:03
-
-
Save blogjunkie/9d2710d73c495bbb1334 to your computer and use it in GitHub Desktop.
Add permalink to genesis [post_date] shortcode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Customize post meta. | |
* | |
* @since 3.0 | |
*/ | |
//* Customize the post meta function | |
add_filter( 'genesis_post_meta', 'child_post_meta_filter' ); | |
function child_post_meta_filter($post_meta) { | |
if ( !is_page() ) { | |
$post_meta = '[post_categories before=""] [post_date]'; | |
} | |
return $post_meta; | |
} | |
//* Add permalink to [post_date] shortcode | |
add_filter( 'genesis_post_date_shortcode', 'child_customize_post_date_shortcode', 10, 2 ); | |
function child_customize_post_date_shortcode( $output, $atts ) { | |
global $post; | |
$defaults = array( | |
'after' => '', | |
'before' => '', | |
'format' => get_option( 'date_format' ), | |
'label' => '', | |
); | |
$atts = shortcode_atts( $defaults, $atts, 'post_date' ); | |
$display = ( 'relative' === $atts['format'] ) ? genesis_human_time_diff( get_the_time( 'U' ), current_time( 'timestamp' ) ) . ' ' . __( 'ago', 'genesis' ) : get_the_time( $atts['format'] ); | |
$new_output = sprintf( '<time %s>', genesis_attr( 'entry-time' ) ) . '<a rel="bookmark" href="' . get_permalink() . '">' . $display . '</a>' . '</time>'; | |
return $new_output; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment