admin管理员组文章数量:1404927
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.
本文标签: phpHow to make function appear in sentence
版权声明:本文标题:php - How to make function appear in sentence? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744868863a2629506.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论