Skip to content

Instantly share code, notes, and snippets.

@fahmi182
Last active May 19, 2017 16:39
Show Gist options
  • Save fahmi182/775ff16775bd90c9e6b6e35f6fa5b4c2 to your computer and use it in GitHub Desktop.
Save fahmi182/775ff16775bd90c9e6b6e35f6fa5b4c2 to your computer and use it in GitHub Desktop.
<?php
function baca_lagi($atts){
//global $post;
$output = '';
extract( shortcode_atts( array(
'ids' => null,
), $atts ) );
$id_array = explode(',', $ids);
$id_implode = implode(',',$id_array);
$args = array(
'post_type' => 'post',
'include' => $id_implode,
'orderby' => 'post__in',
);
$post = get_posts( $args );
if ( !empty( $post ) ) {
foreach ( $post as $posts ) {
$output .= '<a href="'. post_permalink( $posts->ID ) .'" class="bacajuga" target="_blank"><span class="bacaimg">'.get_the_post_thumbnail( $posts->ID, array( 100, 50) ).'</span><span class="bacajudul"><span class="bacablack">Baca juga:</span> '. $posts->post_title .'</span></a>';
}
}
//wp_reset_postdata();
return $output;
}
add_shortcode('bacalagi','baca_lagi');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment