Last active
January 14, 2019 02:43
-
-
Save radarin/98e49009514721c89d71a83e41908801 to your computer and use it in GitHub Desktop.
Ihnhalt der WP DB listen
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* Index erstellen */ | |
add_shortcode('rad-glossar-index', 'radGlossarIndex'); | |
function radGlossarIndex() { | |
global $wpdb; | |
// Alle Einträge listen (Begriff und Beschreibung) | |
$sql = $wpdb->get_results("SELECT glossar_term, glossar_description | |
FROM ".$wpdb->prefix."rad_glossar | |
ORDER BY glossar_term ASC"); | |
$numrows = $wpdb->num_rows; | |
// Anzahl der Datensätze anzeigen | |
$ausgabe = "<p class='glossarnumrows'>Das Glossar enthällt ".$numrows." Einträge.</p>"; | |
// Ausgabe der Datensätze als Liste, Begriff und Beschreibung | |
foreach($sql as $result) | |
{ | |
$ausgabe .= "<p class='glossarterm'>".$result->glossar_term."</p><p class='glossardescription'>".nl2br($result->glossar_description)."</p>"; | |
} | |
return $ausgabe; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment