php - Trouble matching strings (titles) using wp_query

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_q

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 use addslashes().

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 use addslashes().

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 badge
Add a comment  | 

1 Answer 1

Reset to default 0

Solved. After much digging I eventually came upon this:

remove_filter ('the_title', 'wptexturize');

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742387776a4434404.html

相关推荐

  • php - Trouble matching strings (titles) using wp_query

    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_q

    12小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信