开发者

Wordpress functions - get values without echo

开发者 https://www.devze.com 2023-03-06 22:43 出处:网络
How can I programmatically use the data of the bult-in Wordpress functions. E.g. I\'d like to use the data of

How can I programmatically use the data of the bult-in Wordpress functions.

E.g. I'd like to use the data of

the_author_meta('login_name'); 

in a php function. Problem: The function echoes the value by default. In order to use the actual value in a function I can开发者_StackOverflow社区 think of using an output buffer like ...

ob_start();
the_author_meta('login_name');  
$contents = ob_get_contents();
ob_end_clean();

but I was hoping for a better (less bloated) solution.

Any idea how to get the echo values as simple return values instead?


use get_the_author_meta() for return the value.

Note: All of wordpress meta methods (the_post,the_author,the_page etc.) are supports the get_ prefix

0

精彩评论

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