Created
November 17, 2018 00:36
-
-
Save pandanote-info/836031d0e75d478b2f415b113ce1a4b5 to your computer and use it in GitHub Desktop.
Wordpressが使用しているデータベース上に作ったテーブル(catchphraseテーブル)からデータを取り出してHTMLに変換するためのショートコード。
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
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