Skip to content

Instantly share code, notes, and snippets.

@pandanote-info
Created November 17, 2018 00:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pandanote-info/836031d0e75d478b2f415b113ce1a4b5 to your computer and use it in GitHub Desktop.
Save pandanote-info/836031d0e75d478b2f415b113ce1a4b5 to your computer and use it in GitHub Desktop.
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