category bestand alpha filter

This commit is contained in:
Jonas Heinrich 2020-07-11 22:36:15 +02:00
parent 52cdae478b
commit 240f244e2b
2 changed files with 49 additions and 36 deletions

View file

@ -3,27 +3,21 @@
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 '<pre>'; print_r($numberofusers); echo '</pre>';
get_header();
$categories = get_the_category();
$args = array(
'cat' => $categories[0]->cat_ID,
'orderby' => 'title',
'order' => 'ASC',
'nopaging' => true,
);
$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));
array_push($available_chars, mb_substr(get_the_title(),0,1,"utf-8"));
endwhile;
wp_reset_postdata();
};
@ -35,10 +29,11 @@ get_header();
<section class="background-color-white category">
<div class="content-wrap">
<h2>
<?php $categories = get_the_category();
if ( ! empty( $categories ) ) {
echo esc_html( $categories[0]->name );
} ?>
<?php
if ( ! empty( $categories ) ) {
echo esc_html( $categories[0]->name );
}
?>
</h2>
<p>
@ -66,28 +61,28 @@ get_header();
<div id="c139" class="frame frame-default frame-type-list frame-layout-0">
<div class="tx-indexedsearch">
<div class="tx-indexedsearch-searchbox">
<form method="get" role="search" action="<?php echo site_url(/); ?>">
<fieldset>
<div class="tx-indexedsearch-form">
<label for="tx-indexedsearch-searchbox-sword"><?php _e('Ergebnisse filtern', 'kit'); ?>:</label>
<div>
<ul class="catFilter">
<li class='available active'><a href=#>Alle</a></li>
<?php
$chars = array("0-9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "Ä", "Ü", "Ö", "ß");
foreach($chars as $item) {
if (in_array($item, $available_chars)) {
echo "<li class='available'><a href=#>".$item."</a></li>";
} else {
echo "<li>".$item."</li>";
};
<fieldset>
<div class="tx-indexedsearch-form">
<label for="tx-indexedsearch-searchbox-sword">
<?php _e('Ergebnisse filtern', 'kit'); ?>:
</label>
<div>
<ul class="catFilter">
<li class='available active'><a href=#>Alle</a></li>
<?php
$chars = array("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "Ä", "Ü", "Ö");
foreach($chars as $item) {
if (in_array($item, $available_chars)) {
echo "<li class='available'><a href=#>".$item."</a></li>";
} else {
echo "<li>".$item."</li>";
};
?>
</ul>
</div>
};
?>
</ul>
</div>
</fieldset>
</form>
</div>
</fieldset>
</div>
</div>
</div>
@ -109,7 +104,7 @@ get_header();
while ( $query->have_posts() ) :
$query->the_post();
$first_char = substr( esc_html( get_the_title() ) ,0,1 );
$first_char = mb_substr( esc_html( get_the_title() ) ,0,1,"utf-8" );
if ($last_first_char === $first_char) {
echo '<li>