I am using this code which works fine with posts but I am looking to modify it so that the user can specify in the shortcode:
- custom post type name
- taxonomy name
- slug of taxonomy category
Any ideas?
function shortcode_latest_from_blog($atts, $content = null) {
$sliderrandomid = rand();
extract(shortcode_atts(array(
"post_type" => 'post',
"posts" => '8',
"columns" => '4',
"category" => '',
"style" => 'text-normal',
"image_height" => 'auto',
"show_date" => 'true',
"excerpt" => 'true',
), $atts));
ob_start();
?>
<div class="row column-slider">
<div id="slider_<?php echo $sliderrandomid ?>" class="iosSlider blog-posts <?php if($style == 'text-overlay') { ?>slider-center-arrows<?php } ?>" style="min-height:<?php echo $image_height; ?>;height:<?php echo $image_height; ?>;">
<ul class="slider large-block-grid-<?php echo $columns ?> small-block-grid-2">
<?php
$args = array(
'post_status' => 'publish',
'post_type' => $post_type,
'category_name' => $category,
'posts_per_page' => $posts
);
$recentPosts = new WP_Query( $args );
if ( $recentPosts->have_posts() ) : ?>
<?php while ( $recentPosts->have_posts() ) : $recentPosts->the_post(); ?>
//truncated..
Aucun commentaire:
Enregistrer un commentaire