Upload via GUI (39 Dateien)

This commit is contained in:
2026-08-14 07:59:43 +00:00
parent 05a2e1c7b6
commit 90f388f49c
31 changed files with 16919 additions and 5554 deletions
+178
View File
@@ -0,0 +1,178 @@
<?php
/**
* WP Multi Modul: Inhaltsverzeichnis [alphabetical_index]
*
* Automatisch aus wp-multi.php ausgelagert. Wird über den Loader in
* wp-multi.php eingebunden (nur wenn das WP Multi Toolkit aktiv ist).
*/
if (!defined('ABSPATH')) { exit; }
/*
* Index Verzeichnis [alphabetical_index]
*/
// Shortcode zum Erstellen des Indexes
function wp_multi_alphabetical_index($atts) {
// Definiere die Argumente für den Shortcode
$atts = shortcode_atts(array(
'posts_per_page' => 20, // Maximale Beiträge pro Seite
), $atts, 'alphabetical_index');
// Hole alle Beiträge
$args = array(
'post_type' => 'post',
'posts_per_page' => -1,
'orderby' => 'title',
'order' => 'ASC',
);
$posts = get_posts($args);
// Beiträge nach Anfangsbuchstaben gruppieren
$alphabet = range('A', 'Z');
$posts_by_letter = array();
foreach ($posts as $post) {
$first_letter = strtoupper(substr($post->post_title, 0, 1));
if (in_array($first_letter, $alphabet)) {
$posts_by_letter[$first_letter][] = $post;
}
}
// Holen des aktuellen Buchstabens aus der URL
$letter = isset($_GET['letter']) ? strtoupper($_GET['letter']) : ''; // Der Buchstabe aus der URL
// Bestimme, welche Beiträge angezeigt werden
$posts_in_letter = [];
if ($letter && isset($posts_by_letter[$letter])) {
$posts_in_letter = $posts_by_letter[$letter];
}
// Teile die Beiträge in zwei Hälften für die Boxen
$halfway = ceil(count($posts_in_letter) / 2); // Rundet die Hälfte auf
$first_half = array_slice($posts_in_letter, 0, $halfway); // Erste Hälfte der Beiträge
$second_half = array_slice($posts_in_letter, $halfway); // Zweite Hälfte der Beiträge
// Ausgabe
ob_start();
?>
<div class="alphabetical-index">
<!-- Links zu den Buchstaben -->
<div class="alphabet-links">
<?php foreach ($alphabet as $char): ?>
<a href="?letter=<?php echo $char; ?>" class="letter-link"><?php echo $char; ?></a>
<?php endforeach; ?>
</div>
<?php if ($letter): ?>
<!-- Box für den aktuellen Buchstaben -->
<div class="letter-heading-box">
<h2>Beiträge für: <?php echo $letter; ?></h2>
</div>
<!-- Zeige die Beiträge für den ausgewählten Buchstaben in zwei Boxen -->
<div class="letter-pair-container">
<div class="letter-box">
<ul class="post-list">
<?php foreach ($first_half as $post): ?>
<li><a href="<?php echo get_permalink($post->ID); ?>"><?php echo $post->post_title; ?></a></li>
<?php endforeach; ?>
</ul>
</div>
<div class="letter-box">
<ul class="post-list">
<?php foreach ($second_half as $post): ?>
<li><a href="<?php echo get_permalink($post->ID); ?>"><?php echo $post->post_title; ?></a></li>
<?php endforeach; ?>
</ul>
</div>
</div>
<?php endif; ?>
</div>
<style>
.alphabetical-index {
font-family: Arial, sans-serif;
margin: 20px;
}
.alphabet-links {
margin-bottom: 20px;
display: flex;
justify-content: center;
flex-wrap: wrap;
}
.alphabet-links a {
margin-right: 10px;
font-size: 18px;
text-decoration: none;
color: #0073aa;
}
.alphabet-links a:hover {
text-decoration: underline;
}
.letter-heading-box {
margin-bottom: 20px;
background-color: #f0f0f0;
padding: 20px;
text-align: center;
border-radius: 8px;
}
.letter-heading-box h2 {
font-size: 24px;
margin: 0;
}
.letter-pair-container {
display: flex;
gap: 30px;
justify-content: space-between;
}
.letter-box {
width: 48%;
background-color: #f0f0f0;
padding: 20px;
border-radius: 8px;
}
.letter-box h2 {
font-size: 24px;
margin-bottom: 10px;
}
.post-list {
list-style-type: none;
padding: 0;
}
.post-list li {
margin-bottom: 5px;
}
.post-list a {
text-decoration: none;
color: #333;
}
.post-list a:hover {
text-decoration: underline;
}
</style>
<?php
return ob_get_clean();
}
// Shortcode registrieren
add_shortcode('alphabetical_index', 'wp_multi_alphabetical_index');