![](/img/trans.png)
[英]How can consumer listen to all queues present in a channel simultaneously without knowing queue names in php rabbitmq
[英]How can I get WordPress to pull all description metadata fields without knowing their names or length?
如何让 WordPress 找到并显示用户使用的所有描述? 通常,我们网站上的用户会有 2-3 种语言的描述。 其他语言的附加描述字段由插件创建(并由我们的编辑手动填写)。 目前,另一个插件使用此代码来显示用户的主要描述:
$biography = get_the_author_meta( 'description', $user->user_id )
但是,我需要它来提取所有描述字段,例如:
$biography = get_the_author_meta( 'description', $user->user_id ) . $biography = get_the_author_meta( 'description_zh', $user->user_id )
但这很笨拙,我不会提前知道网站将添加多少种语言。 我想也许这样的事情可能会奏效,但没有运气:
$biography = get_the_author_meta( 'description.*', $user->user_id )
我是 PHP 的新手,所以非常感谢任何帮助!
$bio_meta = (array)get_user_meta( $user->user_id );
foreach ( $bio_meta as $key => $value_array ) {
if ( strpos( $key, 'description' ) !== false ) {
$description_values[] = $value_array[0];
}
}
$biography = implode( ' ', $description_values );
将元结果转换为数组可以让生活更轻松,然后只需检查以“描述”开头的每个键。
如果您希望输出包含密钥,则可以更改
$description_values[] = $value_array[0];
进入这个:
$description_values[] = array( $key => $value_array[0] );
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.