Für mein Plug-In habe ich folgenden Shortcode erstellt:
PHP
function listbooks_handler() {
//run function that actually does the work of the plugin
$bookoutput = listbooks_function();
//send back text to replace shortcode in post
return $bookoutput;
}
function listbooks_function() {
// Datensätze holen
$table_name = $wpdb->prefix . "mybooks";
print "<h1>Wanderführer Übersicht ...</h1>";
// Daten ausgeben
$listbookdata = $wpdb->get_results(
"
SELECT book_id, book_title
FROM $table_name
ORDER BY book_id ASC
"
);
print "<ul id=\"Navigation\">";
foreach ( $listbookdata as $listbooks )
{
$book_id = $listbooks->book_id;
$book_title = $listbooks->book_title;
print"<li><a href=\"book.htm\">{$book_title}</a></li>";
}
print "</ul>";
}
?>
Alles anzeigen
Ich erhalte aber eine Fehlermeldung bei der Abfrage der Datenbank: