admin管理员组文章数量:1335847
I'm repairing an old site on which we match the titles of two types of posts to link them together. There is a wp_query
which uses 'title' => get_the_title()
to do this, but it only works some of the time.
My first solution was to clean the title string using html_entity_decode()
. This works on 90% of cases and I need to retain this processing to deal with these posts.
However I am now stuck with a particular outlier, which has a title like this It’s Raining Outside My Mother’s House
.
If I compare
==
the two values, with no preprocessing, it returns true, but via the query it fails.If I paste the title value into the query it works, and if I use
addslashes()
it still works.But if I use
get_the_title()
in the query (as I need to for the final code) it fails, even if I useaddslashes()
.
Is there another function I need in order to clean the title string? Can you suggest an 'all cases' technique?
Thanks
I'm repairing an old site on which we match the titles of two types of posts to link them together. There is a wp_query
which uses 'title' => get_the_title()
to do this, but it only works some of the time.
My first solution was to clean the title string using html_entity_decode()
. This works on 90% of cases and I need to retain this processing to deal with these posts.
However I am now stuck with a particular outlier, which has a title like this It’s Raining Outside My Mother’s House
.
If I compare
==
the two values, with no preprocessing, it returns true, but via the query it fails.If I paste the title value into the query it works, and if I use
addslashes()
it still works.But if I use
get_the_title()
in the query (as I need to for the final code) it fails, even if I useaddslashes()
.
Is there another function I need in order to clean the title string? Can you suggest an 'all cases' technique?
Thanks
Share Improve this question asked May 30, 2020 at 8:29 byzantine cucumberbyzantine cucumber 1011 bronze badge1 Answer
Reset to default 0Solved. After much digging I eventually came upon this:
remove_filter ('the_title', 'wptexturize');
本文标签: phpTrouble matching strings (titles) using wpquery
版权声明:本文标题:php - Trouble matching strings (titles) using wp_query 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742387775a2465379.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论