From 49b7e41de2803a042b6d7f99e1bc81def191e572 Mon Sep 17 00:00:00 2001 From: tomplays Date: Sun, 19 Jun 2016 14:58:34 +0200 Subject: [PATCH] media cat/tag / single view and grid view --- theme/attachment.php | 38 ++++++++++++++++++++++++++++ theme/lib/nuitdebout/utils.php | 8 ++++++ theme/mediasquery.php | 22 ++++++++++++++++ theme/taxonomy-media_category.php | 23 +++++++++++++++++ theme/taxonomy-media_tag.php | 23 +++++++++++++++++ theme/templates/content-search.php | 7 ++++- theme/templates/entry-taxonomies.php | 8 +++--- 7 files changed, 124 insertions(+), 5 deletions(-) create mode 100644 theme/attachment.php create mode 100644 theme/mediasquery.php create mode 100644 theme/taxonomy-media_category.php create mode 100644 theme/taxonomy-media_tag.php diff --git a/theme/attachment.php b/theme/attachment.php new file mode 100644 index 0000000..c2d5c29 --- /dev/null +++ b/theme/attachment.php @@ -0,0 +1,38 @@ +
+ +
+
+ + +

Downloads: + ' . $name . ''; + + if($image_size == 'thumbnail'){ + $c = $image[0]; + + } + } + echo ''; + echo implode( ' | ', $images ); + + + + ?> + +

+ + +
+
+
+
\ No newline at end of file diff --git a/theme/lib/nuitdebout/utils.php b/theme/lib/nuitdebout/utils.php index daeb0f4..f015b99 100644 --- a/theme/lib/nuitdebout/utils.php +++ b/theme/lib/nuitdebout/utils.php @@ -21,3 +21,11 @@ function getAttachmentThumb($id) { $url = wp_get_attachment_image_src($thumb , [330, 180])[0]; return $url; } +function attachment_search( $query ) { + if ( $query->is_search ) { + $query->set( 'post_type', array( 'post', 'attachment' ) ); + $query->set( 'post_status', array( 'publish', 'inherit' ) ); + } + return $query; +} +add_filter( 'pre_get_posts', 'attachment_search' ); \ No newline at end of file diff --git a/theme/mediasquery.php b/theme/mediasquery.php new file mode 100644 index 0000000..3c7406e --- /dev/null +++ b/theme/mediasquery.php @@ -0,0 +1,22 @@ + 'attachment', + 'post_status' => 'any' +); +$the_query = new WP_Query( $args ); +if ( $the_query->have_posts() ) { + while ( $the_query->have_posts() ) { + $the_query->the_post(); + get_template_part('templates/entry-taxonomies'); + echo wp_get_attachment_image( get_the_ID(), 'thumbnail' ); + } +} else { + // no attachments found +} +wp_reset_postdata(); \ No newline at end of file diff --git a/theme/taxonomy-media_category.php b/theme/taxonomy-media_category.php new file mode 100644 index 0000000..9aa66fa --- /dev/null +++ b/theme/taxonomy-media_category.php @@ -0,0 +1,23 @@ +
+ + + + +
> +
+ + +
+
+ + +
+
+
+ + + +
\ No newline at end of file diff --git a/theme/taxonomy-media_tag.php b/theme/taxonomy-media_tag.php new file mode 100644 index 0000000..9aa66fa --- /dev/null +++ b/theme/taxonomy-media_tag.php @@ -0,0 +1,23 @@ +
+ + + + +
> +
+ + +
+
+ + +
+
+
+ + + +
\ No newline at end of file diff --git a/theme/templates/content-search.php b/theme/templates/content-search.php index 79339c8..71d69a6 100644 --- a/theme/templates/content-search.php +++ b/theme/templates/content-search.php @@ -1,9 +1,14 @@
>
+ +

- +
diff --git a/theme/templates/entry-taxonomies.php b/theme/templates/entry-taxonomies.php index e64c590..57d1a22 100644 --- a/theme/templates/entry-taxonomies.php +++ b/theme/templates/entry-taxonomies.php @@ -1,6 +1,6 @@ ID, $tax ); if($categories){ @@ -13,17 +13,17 @@
$categories ) : ?> - + Classé dans - + | name ) ?> - , + ,