Skip to content

Instantly share code, notes, and snippets.

@ScarletPonytail
Last active September 6, 2017 09:52
Show Gist options
  • Save ScarletPonytail/b1078ab993ec391c9739d89ab5ec3242 to your computer and use it in GitHub Desktop.
Save ScarletPonytail/b1078ab993ec391c9739d89ab5ec3242 to your computer and use it in GitHub Desktop.
WordPress - Blog Post Elements / Adding slide image based on Featured Image for page / Except / Date / Author
// User this just to call the image that's the featured image for that page surrounded by the 'img tag
<?php echo get_the_post_thumbnail(); ?>
// If you want more control over the size of the image
<?php echo get_the_post_thumbnail( get_the_ID(), 'full' ); ?>
// If statement for Thumbnail
<?php if ( has_post_thumbnail()) : // Check if thumbnail exists ?>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
<?php the_post_thumbnail(array(120,120)); // Declare pixel size you need inside the array ?>
</a>
<?php endif; ?>
// Display the thumbnail image url only
<?php echo the_post_thumbnail_url(); ?>
// Displaying the except instead of concatinated blog content
<p><?php the_excerpt(__('(more…)')); ?></p>
// The Title including link
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
// The date
<span class="date"><?php the_time('jS F Y'); ?> | </span>
// The Author
<span class="author"><?php _e( 'By', 'html5blank' ); ?> <?php the_author_posts_link(); ?></span>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment