I am trying to make a WordPress shortcode a little different then it is working now and that is when there is any value filled in then the object will be visible.
I have now this:
function open_books( $atts ) {
$a = shortcode_atts( array(
'amount' => 5
), $atts );
$args = array(
'posts_per_page' => intval( $a['amount'] ),
'post_type' => 'all_books',
);
$the_query = Books::search()->where('bookdate', '2019-03-30 11:00:00');
if ( $the_query->have_posts() ) {
$ret = '<div id="entity-items">';
$i = 0;
while ( $the_query->have_posts() ) {
if( $i < $a['amount'] ) {
$i++;
$the_query->the_post();
$ret .= Books::template('item')->cache();
}
}
}
$ret .= '</div>';
wp_reset_postdata();
return $ret;
}
add_shortcode( 'open_books', 'open_books' );
But this is online showing the object with that specific date but i want that the query will show all objects that haves a date.