admin管理员组文章数量:1278881
I try to to make compare by company title so I need to send this title as variable to meta query value. I use this code and get value = NULL. Please tell me why?
$company_name = the_title( );
$params = array(
'meta_query' => array(
array(
'key' => 'user_company',
'value' => $company_name
)
)
);
I try to to make compare by company title so I need to send this title as variable to meta query value. I use this code and get value = NULL. Please tell me why?
$company_name = the_title( );
$params = array(
'meta_query' => array(
array(
'key' => 'user_company',
'value' => $company_name
)
)
);
Share
Improve this question
asked Oct 8, 2021 at 12:39
MegosMegos
52 bronze badges
4
|
1 Answer
Reset to default 0Use get_the_title
to get the title. the_title
is for when you want to output directly to the browser.
本文标签: meta queryHow to send variable to wp metaquery value
版权声明:本文标题:meta query - How to send variable to wp meta_query value? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741280244a2369967.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
the_title
does not return the title, it echo's the title, it's the wrong function – Tom J Nowell ♦ Commented Oct 8, 2021 at 13:40the_title
is the wrong function, even if it returns a value it still outputs to the browser, you must use the dedicated function that returns the title instead,get_the_title
– Tom J Nowell ♦ Commented Oct 8, 2021 at 13:52