Retrieving topic information from a style.css file in Wordpress

With a Wordpress theme, you need to add information to the top of the style.css file:

eg; for the default theme:

/*
Theme Name: WordPress Default
Theme URI: http://wordpress.org/
Description: The default WordPress theme based on the famous <a href="http://binarybonsai.com/kubrick/">Kubrick</a>.
Version: 1.6
Author: Michael Heilemann
Author URI: http://binarybonsai.com/
Tags: blue, custom header, fixed width, two columns, widgets
*/

Are there any wordpress features to get this information programmatically?

+3
source share
3 answers

You can use get_theme_data()either this PHP script, which I put together quickly:

<?php
$file = file('your file location');
$contents = '';
foreach($file as $lines => $line){
$contents .= $line;
}
preg_match('!/\*[^*]*\*+([^/][^*]*\*+)*/!', $contents, $themeinfo);
echo nl2br($themeinfo[0]);
?>
+3
source

, get_theme_data WP 3.4 wp_get_theme. styles.css, get_theme_data, ThemeURI , Theme URL.

http://codex.wordpress.org/Function_Reference/wp_get_theme

+1
source

Source: https://habr.com/ru/post/1724636/


All Articles