Skip to content

Instantly share code, notes, and snippets.

@taptapdan
Last active December 14, 2015 17:36
Show Gist options
  • Select an option

  • Save taptapdan/4e877ba560020cc02db1 to your computer and use it in GitHub Desktop.

Select an option

Save taptapdan/4e877ba560020cc02db1 to your computer and use it in GitHub Desktop.
Wordpress, Post Formats, Link -- Adding Support to Widgets
// functions.php
add_theme_support( 'post-formats', array( 'link' ) );
// wp-content/plugins/recent-posts-by-category-widget/recent-posts-by-category-widget.php
if ( get_post_format() == 'link' ) {
echo '<li>';
echo '<a href="' . get_the_content() . '">' . get_the_title() . '</a>';
if ( $show_date ) echo '<span class="post-date">' . get_the_time( get_option( 'date_format' ) ) . '</span>';
echo '</li>';
} else {
echo '<li>';
echo '<a href="' . get_permalink() . '">' . get_the_title() . '</a>';
if ( $show_date ) echo '<span class="post-date">' . get_the_time( get_option( 'date_format' ) ) . '</span>';
echo '</li>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment