Skip to content

Instantly share code, notes, and snippets.

@pandanote-info
Created November 17, 2018 00:36
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
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