Skip to content

Instantly share code, notes, and snippets.

@blogjunkie
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blogjunkie/9d2710d73c495bbb1334 to your computer and use it in GitHub Desktop.
Save blogjunkie/9d2710d73c495bbb1334 to your computer and use it in GitHub Desktop.
Add permalink to genesis [post_date] shortcode
<?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