I'm completely lost in code as always so I'd rather ask before I spend hours with it.
Can i create a shortcode to display fields as gallery or whatever?
Images needs to use foreach to display it.
foreach ( $digall as $key => $value ) {
$image = RWMB_Image_Field::file_info( $value, ['size' => 'large'] );
echo '<div class="swiper-slide"><img alt="" src="'. $image['url'] . '" /></div>';
}
But i need to create shortcode..
function digallery($atts) {
$a = shortcode_atts( array(
'posts_per_page' => '',
'gellery_id' => ''
), $atts );
$digalleries = rwmb_meta( 'digallery' );
$digall = $digalleries['gallimage'];// Illegal string offset 'gallimage'
$digallery = '';
$post_in = esc_attr($a['testimonial_id']);
$posts_per_page = esc_attr($a['posts_per_page']);
$post_artay = explode(',', $post_in);
$args = array(
'post__in' => $post_artay,
'posts_per_page' => $posts_per_page,
'post_type' => 'divart_gallery',
'order_by' => 'post__in',
);
// the query
$the_query = new WP_Query( $args );
if ( $the_query->have_posts() ) :
while ( $the_query->have_posts() ) : $the_query->the_post();
$digallery.= RWMB_Image_Field::file_info( $value, ['size' => 'large'] ); // to loop ?
$digallery.= '<div class="title">'.get_the_title().'</div>';
$digallery.= '<div class="content">'.get_the_content().'</div>';
$digallery.='<div class="date">'.get_the_date().'</div>';
$digallery.='<div class="author">'.get_the_author().'</div>';
endwhile;
endif;
return $digallery;
}
add_shortcode('gallery', 'digallery' );
//and shortcode would by
[gallery posts_per_page="1" gellery_id="217"]
Would anything like that be possible?
Thank you