From 0702f7afa95c5cbfd983cd5f8929e2b66e1f0a4c Mon Sep 17 00:00:00 2001 From: "Steven A. Zahm" Date: Tue, 13 Nov 2018 12:18:19 -0500 Subject: [PATCH] Add support for querying multiple categories. --- display-posts-shortcode-remote.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/display-posts-shortcode-remote.php b/display-posts-shortcode-remote.php index 16725d0..d83eb56 100644 --- a/display-posts-shortcode-remote.php +++ b/display-posts-shortcode-remote.php @@ -252,6 +252,11 @@ if ( ! class_exists( 'Display_Posts_Remote' ) ) { if ( ! empty( $atts['category_id'] ) ) { + if ( is_array( $atts['category_id'] ) ) { + + $atts['category_id'] = implode( ',', $atts['category_id'] ); + } + $url = add_query_arg( 'categories', $atts['category_id'], $url ); } @@ -331,7 +336,7 @@ if ( ! class_exists( 'Display_Posts_Remote' ) ) { $defaults = Display_Posts_Remote()->getDefaults(); $atts = shortcode_atts( $defaults, $untrusted, 'display-posts-remote' ); - $atts['category_id'] = absint( $atts['category_id'] ); + $atts['category_id'] = wp_parse_id_list( $atts['category_id'] ); $atts['content_class'] = array_map( 'sanitize_html_class', ( explode( ' ', $atts['content_class'] ) ) ); $atts['date_format'] = sanitize_text_field( $atts['date_format'] ); $atts['include_content'] = self::toBoolean( $atts['include_content'] );