have_posts() ) : $html = '
'; $html .= ''; $html .= '
'; endif; // Restore original Post Data. wp_reset_postdata(); // Allow devs to hook in stuff after the loop. do_action( 'arpw_after_loop', $args ); // Use this hook to add content to all query do_action( 'arpw_after_loop_' . $id, $args ); // Use this hook to add content to spesific query // Return the related posts markup. return wp_kses_post( $args['before'] ) . $html . wp_kses_post( $args['after'] ); } /** * The posts query. * * @since 0.0.1 * @param array $args * @return array */ function arpw_get_posts( $args, $id ) { // Query arguments. $query = array( 'offset' => $args['offset'], 'posts_per_page' => $args['limit'], 'orderby' => $args['orderby'], 'post_type' => $args['post_type'], 'post_status' => $args['post_status'], 'ignore_sticky_posts' => $args['ignore_sticky'], ); // Limit posts based on category. if ( ! empty( $args['cat'] ) ) { $query['category__in'] = $args['cat']; } // Limit posts based on post tag. if ( ! empty( $args['tag'] ) ) { $query['tag__in'] = $args['tag']; } /** * Taxonomy query. * Prop Miniloop plugin by Kailey Lampert. */ if ( ! empty( $args['taxonomy'] ) ) { parse_str( $args['taxonomy'], $taxes ); $tax_query = array(); foreach( array_keys( $taxes ) as $k => $slug ) { $ids = explode( ',', $taxes[ $slug ] ); $tax_query[] = array( 'taxonomy' => $slug, 'field' => 'id', 'terms' => $ids, 'operator' => 'IN' ); } $query['tax_query'] = $tax_query; } // Allow plugins/themes developer to filter the default query. $query = apply_filters( 'arpw_query', $query ); // DEPRECATED // $query = apply_filters( 'arpw_query_' . $id, $query ); // New filter, will introduce in version 2.5.0 // Perform the query. $posts = new WP_Query( $query ); return $posts; }