Team:ETH Zurich/labblog/catfunction.php
From 2014.igem.org
(Difference between revisions)
Clormeau (Talk | contribs)
(Created page with "function jc_post_by_category($atts, $content = null) { extract(shortcode_atts(array( "nb" => '5', "orderby" => 'post_date', "order" => 'DESC', ...")
Newer edit →
(Created page with "function jc_post_by_category($atts, $content = null) { extract(shortcode_atts(array( "nb" => '5', "orderby" => 'post_date', "order" => 'DESC', ...")
Newer edit →
Revision as of 16:35, 6 July 2014
function jc_post_by_category($atts, $content = null) {
extract(shortcode_atts(array( "nb" => '5', "orderby" => 'post_date', "order" => 'DESC', "category" => '1' ), $atts)); global $post; $tmp_post = $post; $myposts = get_posts('showposts='.$nb.'&orderby='.$orderby.'&category='.$category);$out = '
- ';
foreach($myposts as $post){
setup_postdata( $post );
$out .= '
- <a href="'.get_permalink().'">'.the_title("","",false).'</a> ';
}$out .= '';
wp_reset_postdata(); $post = $tmp_post; return $out;
} add_shortcode("post-by-category", "jc_post_by_category");