我正在尝试使用API获得WordPress主题名称。我已经尝试过此代码,但是我希望使用自定义网址获得相同的结果:
function theme_list_function(){
// Get a list of themes
$list = wp_get_themes();
// Return the value
var_dump($list);
}
此代码将返回当前的WordPress主题列表。我希望主题列表形成一个像xyz.com这样的URL
答案 0 :(得分:0)
我已经使用以下代码实现了这一点:
$target_site = ""; // put your wordpress url here
$src = file_get_contents( $target_site );
preg_match("/\<link rel='stylesheet'.*href='(.*?style\.css.*?)'.*\>/i", $src, $matches );
if( $matches ) {
$style_href = trim( $matches[1] );
$style_src = file_get_contents( $style_href );
preg_match( "/\Theme Name:(.*?)\n/i", $style_src, $theme_name );
$theme_name = str_replace(' ', '', $theme_name[1]);
var_dump( $theme_name );
}