Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Wordpressが使用しているデータベース上に作ったテーブル(catchphraseテーブル)からデータを取り出してHTMLに変換するためのショートコード。
function dump_catchphrase() {
global $wpdb;
$cc = '<ol>';
$rows = $wpdb->get_results("select catchphrase from catchphrase",ARRAY_A);
$rop = $wpdb->num_rows;
foreach ($rows as $row) {
$cc .= '<li>'.$row['catchphrase'].'</li>';
}
return $cc . '</ol>';
}
add_shortcode('dump-catchphrase','dump_catchphrase');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.