Skip to content

Instantly share code, notes, and snippets.

@hsquareweb
Created March 29, 2012 22:33
Show Gist options
  • Save hsquareweb/2244418 to your computer and use it in GitHub Desktop.
Save hsquareweb/2244418 to your computer and use it in GitHub Desktop.
WP: Shortcode Function
// Shortcode to insert the latest article in the prayer corner section
function sc_prayercorner (){
$args = array(
'numberposts' => 1,
'post_type' => 'prayer_corner',
'post_status' => 'publish',
'orderby' => 'post_date'
);
$postslist = get_posts( $args );
foreach($postslist as $post) : setup_postdata($post);
$tmpString = '<div>' . get_the_post_thumbnail($id, array(460,auto));
$tmpString = $tmpString . '<h3>' . $post->post_title;
$tmpString = $tmpString . '</h3><p>' . $post->post_content;
$tmpString = $tmpString . '</p></div>';
return $tmpString;
endforeach;
}
add_shortcode('prayercorner', 'sc_prayercorner');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment