I have a function to show theme details and want to put it in a sentence. Like: The "theme" developed by "author". And it will contain links.
I tried printf, did get the correct result.
function logbook_info() {
$theme_logbook = wp_get_theme();
echo esc_html( $theme_logbook->get( 'TextDomain' ) );
echo esc_html( $theme_logbook->get( 'ThemeURI' ) );
echo esc_html( $theme_logbook->get( 'AuthorURI' ) );
}
add_action( 'logbookinfo', 'logbook_info' );
I have a function to show theme details and want to put it in a sentence. Like: The "theme" developed by "author". And it will contain links.
I tried printf, did get the correct result.
function logbook_info() {
$theme_logbook = wp_get_theme();
echo esc_html( $theme_logbook->get( 'TextDomain' ) );
echo esc_html( $theme_logbook->get( 'ThemeURI' ) );
echo esc_html( $theme_logbook->get( 'AuthorURI' ) );
}
add_action( 'logbookinfo', 'logbook_info' );
Share
Improve this question
edited Dec 31, 2019 at 19:22
butlerblog
5,1213 gold badges28 silver badges44 bronze badges
asked Dec 31, 2019 at 10:55
webfuelcodewebfuelcode
212 bronze badges
2 Answers
Reset to default 1You can use below code to display theme detail sentence. I have use wp_footer
action,You can change hook as per your requirement.
function logbook_info() {
$theme_logbook = wp_get_theme();
$theme_name = esc_html( $theme_logbook->get( 'Name' ) );
$theme_uri = esc_html( $theme_logbook->get( 'ThemeURI' ) );
$theme_author = esc_html( $theme_logbook->get( 'Author' ) );
$theme_author_uri = esc_html( $theme_logbook->get( 'AuthorURI' ) );
$theme_html = '<a href="'.$theme_uri.'">'.$theme_name.'</a>';
$author_html = '<a href="'.$theme_author_uri.'">'.$theme_author.'</a>';
echo "The ".$theme_html." developed by ".$author_html;
}
add_action( 'wp_footer', 'logbook_info' );
It will add theme detail in footer : https://prnt.sc/qhva3o
function logbook_info() {
$theme_logbook = wp_get_theme();
echo 'The'.esc_html( $theme_logbook->get( 'TextDomain' ) ). 'Developed by '.
esc_html( $theme_logbook->get( 'AuthorURI' ) );
}
add_action( 'logbookinfo', 'logbook_info' );
Try this.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744868864a4598138.html
评论列表(0条)