From 77306b737bf6122d60e3564e0cf07f0bbcc25cb9 Mon Sep 17 00:00:00 2001 From: Jonas Heinrich Date: Fri, 12 Jun 2020 15:09:54 +0200 Subject: [PATCH] starting to implement alphabetical filter in category page --- kit/category-bestand.php | 39 ++++++++++++++++++++++++++++++++++++--- kit/functions.php | 8 ++++++++ kit/style.css | 20 ++++++++++++++++++++ 3 files changed, 64 insertions(+), 3 deletions(-) diff --git a/kit/category-bestand.php b/kit/category-bestand.php index 128308d..ec3cb7c 100644 --- a/kit/category-bestand.php +++ b/kit/category-bestand.php @@ -4,6 +4,30 @@ Template Name: Bestand */ get_header(); + + + $numberofusers = $wpdb->get_results( " + SELECT post_title + FROM {$wpdb->posts} + WHERE post_type = 'post' and post_status = 'publish' + ORDER BY post_title ASC" ); + //echo '
'; print_r($numberofusers); echo '
'; + + $args = array( + 'cat' => $categories[0]->cat_ID, + 'orderby' => 'title', + 'order' => 'ASC', + ); + $query = new WP_Query( $args ); + $available_chars = []; + if ( $query->have_posts() ) { + while ( $query->have_posts() ) : + $query->the_post(); + array_push($available_chars, substr(get_the_title(),0,1)); + endwhile; + wp_reset_postdata(); + }; + ?>
@@ -47,9 +71,18 @@ get_header();
-
    -
  • Alle
  • -
  • A
  • +
      +
    • Alle
    • + ".$item.""; + } else { + echo "
    • ".$item."
    • "; + }; + }; + ?>
diff --git a/kit/functions.php b/kit/functions.php index 9d6261c..d9f1470 100644 --- a/kit/functions.php +++ b/kit/functions.php @@ -322,6 +322,14 @@ function kit_customize_css() background-color: ; } + ul.catFilter li.available:hover { + background-color: ; + } + + ul.catFilter li.active { + background-color: ; + } +