Skip to content

Instantly share code, notes, and snippets.

@DrewAPicture
Created June 10, 2012 18:11
Show Gist options
  • Save DrewAPicture/2906793 to your computer and use it in GitHub Desktop.
Save DrewAPicture/2906793 to your computer and use it in GitHub Desktop.
Link to SmugMug gallery from Events Archive + SmugMug thumb as link
<?php if ( $recent->have_posts() ) : while ( $recent->have_posts() ) : $recent->the_post();
// Pull the URL from the_content()
$link = esc_url( get_the_content() );
// Check if it's a properly formed URL, append http:// if not. Don't want user to struggle here
if ( ! preg_match('/^http:\/\//', $link ) )
$link = 'http://' . $link;
// Setup args for our oEmbed
$smug_args = array(
'width' => 425,
'height' => 335
);
// Get our oEmbed HTML
$link_output = wp_oembed_get( $link, $smug_args );
?>
// Build our custom-linked events ?>
<article <?php post_class('recent-event'); ?>>
<?php if ( $link_output ) echo $link_output; ?>
<h1><a href="<?php echo $link; ?>" title="<?php the_title_attribute(); ?>" target="_new"><?php the_title(); ?></a></h1>
<?php edit_post_link( __( '{ Edit Event }' ), '<span class="small fr">', '</span>' ); ?>
</article><!-- /.post -->
<?php endwhile; else: ?>
<article <?php post_class(); ?>>
<h3>Sorry, no events were found.</h3>
</article><!-- /.post -->
<?php endif; wp_reset_postdata(); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment