开发者

wordpress custom theme option

开发者 https://www.devze.com 2023-01-16 12:56 出处:网络
I\'m working on a custom wordpress theme with a little bit of backend admin system. Why I need to declare

I'm working on a custom wordpress theme with a little bit of backend admin system.

Why I need to declare


global $options;
foreach ($options as $value) {
if (get_settings( $value['id'] ) === FALSE) { $$value['i开发者_开发百科d'] = $value['std']; } else { $$value['id'] = get_settings( $value['id'] ); }
}

multiple times in header and footer? Because my index.php file includes header.php and footer.php. Why can't I declare one time at the header.

thanks :)


I'm guessing it has to do with your usage of $options and variable scope. While you'll probably need global $options wherever you want to use that variable, you probably only need the foreach loop there only the first time.

Also, get_settings() is deprecated, use get_options() instead.

0

精彩评论

暂无评论...
验证码 换一张
取 消