Created
March 29, 2012 22:33
-
-
Save hsquareweb/2244418 to your computer and use it in GitHub Desktop.
WP: Shortcode Function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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