wordpress 管理パネル用のカスタム画像アップローダを作成しましたが、wp_options テーブルからデータを取得する必要があります。以下の関数を書きました:
//function to get all slider images
function getSliderImages(){
global $wpdb, $theme_shortname;
$query = "SELECT * FROM $wpdb->options AS o1
WHERE o1.option_name LIKE '%".$theme_shortname."_header_image%'";
$imgs = $wpdb->get_results($query);
$images = array();
//loop through images and remove unusable results
foreach($imgs as $i){
$id = substr($i['option_name'],0,-1);
if(is_numeric($id)){
$images[] = $i['option_value'];
}
}
return($images);
}
フロントエンドの header.php で返された配列にアクセスするにはどうすればよいですか? この関数は現在、themes/themename/functions.php にあります