Created
January 31, 2017 18:43
-
-
Save devuri/808c15c637540762c3cd01a67e619f56 to your computer and use it in GitHub Desktop.
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
<?php | |
// shortcode | |
add_shortcode( 'foobar', 'foobar_func' ); | |
function foobar_func( $atts ){ | |
// php only | |
$recent_posts = wp_get_recent_posts(array( | |
'numberposts' => 3, | |
'category' => 15, | |
'post_status' => 'publish' | |
)); | |
foreach( $recent_posts as $recent ){ | |
echo '<a href="'. get_permalink($recent["ID"]) . ' "> ' . $recent[post_title] . '</a>' ; | |
echo ' | '. date( 'l F jS', strtotime( $recent['post_date'] ) ); | |
echo '<hr/>'; | |
} wp_reset_query(); | |
} | |
?> | |
[foobar] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment