CRP always includes self article
-
I use crp in a theme template. However, I have the issue that CRP array includes the article itself for which CRP should be retrieved. Even if I exclude the own ID explicitly the self post still shows up. I tried both echo_crp() function and the shortcode. Can you support here? Thanks a lot!
<?php if (function_exists('echo_crp')) { echo_crp(array()); } ?><?php echo do_shortcode('[crp exclude_post_ids="' . get_the_ID() . '"]') ?>
-
What’s the page I can see this. It’s quite strange this happens as the plugin is explicitly set to exclude the current post ID.
https://github.com/WebberZone/contextual-related-posts/blob/master/includes/class-crp-query.php#L343
You can see it here on these sites (scroll to bottom): https://www.globetrotter.de/magazin/von-trient-in-die-berge/
https://www.globetrotter.de/magazin/40-x-ortlieb/CRP version 3.2.3 is installed. Thanks for support.
Just checked this out. Are you in a position to run Query Monitor to study what the query is. I’m quite confused as to which stage this is breaking down.
Yes, I have a staging env running. Cannot give you access to it though. The query which is sent by the plugin is the following. What strikes me is the first WHERE clause containing 1=1. What do you think?
SELECT wp_posts.*, MATCH (wp_posts.post_title,wp_posts.post_content) AGAINST ('Ins Abenteuerland Christo Förster Unter freiem Himmel schlafen, grandiose Landschaften entdecken, eigene Grenzen entdecken - überwinden. Christo will aufzeigen, schön unser Zuhause schützenswert Natur gleich vor Haustür. Dafür denkt er größer: All Erlebte soll auf Leinwand. Mithilfe Crowdfunding-Kampagne hat er den Grundstein den Film gelegt, Globetrotter Ausrüstung neuseeländischen Merino-Experten Icebreaker runden auf, um ihn bei seinem Vorhaben unterstützen. \"Abenteuerland\" - Zusammenfassung. Abenteurer Buchautor, Abenteurer Podcaster. seinem Motto „Raus machen“ inspiriert Christo Foerster immer wieder dazu, mehr Freiheit Abenteuer im Hier Jetzt …') as score FROM wp_posts WHERE 1=1 AND ( ( wp_posts.post_date >= '2019-06-20 00:00:00' AND wp_posts.post_date <= '2022-06-19 19:44:21' ) ) AND wp_posts.ID NOT IN (3153,3189,3127,6107,3055,6984,8798,8782,8707,10254,8860,8908,9657,9007,11118,12618,12688,22315,22535,22839,22599,32649,31735,38236,34864,45135,44470,43809,54951,45369,56819,62479,62798,64401,64239,61065,67085) AND ( wp_posts.ID NOT IN ( SELECT object_id FROM wp_term_relationships WHERE term_taxonomy_id IN (240) ) ) AND wp_posts.post_type IN ('post', 'podcast') AND ((wp_posts.post_status = 'publish' OR wp_posts.post_status = 'inherit')) AND MATCH (wp_posts.post_title,wp_posts.post_content) AGAINST ('Ins Abenteuerland Christo Förster Unter freiem Himmel schlafen, grandiose Landschaften entdecken, eigene Grenzen entdecken - überwinden. Christo will aufzeigen, schön unser Zuhause schützenswert Natur gleich vor Haustür. Dafür denkt er größer: All Erlebte soll auf Leinwand. Mithilfe Crowdfunding-Kampagne hat er den Grundstein den Film gelegt, Globetrotter Ausrüstung neuseeländischen Merino-Experten Icebreaker runden auf, um ihn bei seinem Vorhaben unterstützen. \"Abenteuerland\" - Zusammenfassung. Abenteurer Buchautor, Abenteurer Podcaster. seinem Motto „Raus machen“ inspiriert Christo Foerster immer wieder dazu, mehr Freiheit Abenteuer im Hier Jetzt …') GROUP BY wp_posts.ID ORDER BY score DESC LIMIT 0, 3If you need anything else, please let me know.
I think it might be this part:
AND wp_posts.ID NOT IN (3153,3189,3127,6107,3055,6984,8798,8782,8707,10254,8860,8908,9657,9007,11118,12618,12688,22315,22535,22839,22599,32649,31735,38236,34864,45135,44470,43809,54951,45369,56819,62479,62798,64401,64239,61065,67085)Do you see the post ID showing up here? How are you setting all the other post IDs?
Also, can you try a setting in the Edit screen with the meta box at the bottom – there is an option to exclude this post.
No, the post id of the tested post is 60706. So, the post id is not contained in the part above. The only setting I have active is the exclusion of posts from category 240. So, I suppose that the ids are generated from that setting.
I saw the option to exclude the post in the metabox but I don’t want it to be excluded in general. Could still be relevant for other posts. Also notice that I have several posts which include themselves as related posts. It’s not only the one post from above.
Do you think a plugin conflict could be present and causing this issue?
I just set the setting “Exclude this post from the related posts list”. It is still displayed as related post…
There is definitely something that is overwriting the queries. E.g. the category point is captured in the separate line.
However, the exclusion is kicking in and changing or ignoring all the other IDs.
Not sure if it is a plugin clash or some other code clash. Do you by any chance have any other code either using the Code Snippet plugin, in your theme’s functions.php or similar related to the plugin?
Worth making a note of the settings you’ve change and resetting the plugin settings first.
The topic ‘CRP always includes self article’ is closed to new replies.