Title: Exclude not working when function included manually
Last modified: October 22, 2020

---

# Exclude not working when function included manually

 *  [mx5gr](https://wordpress.org/support/users/mx5gr/)
 * (@mx5gr)
 * [5 years, 7 months ago](https://wordpress.org/support/topic/exclude-not-working-when-function-included-manually/)
 * Hello again!
 * I noticed that if the CRP functionality is added via
 * `if ( function_exists( 'echo_crp' ) ) { echo_crp(); }`
 * then no exclusions based on post IDs are effective. I tried to exclude a specific
   ID from both Settings -> CRP -> Output and from within the specific post item(
   by selecting the respective box), but both were ineffective. It seems that as
   soon as the CRP function is added via the way above, then no check is performed
   in internal logic for exclusions.
 * If this is the case, how can the exclusions, either via the plugin settings or
   the individual post specific toggle, can be respected if the CRP functionality
   is added manually?
 * Wordpress 5.5.1 , CRP 2.9.4
 * Thank you!

Viewing 7 replies - 1 through 7 (of 7 total)

 *  Plugin Author [Ajay](https://wordpress.org/support/users/ajay/)
 * (@ajay)
 * [5 years, 7 months ago](https://wordpress.org/support/topic/exclude-not-working-when-function-included-manually/#post-13569465)
 * You can pass these as parameters to the function – same ones as used in the shortcode.
   In this case: exclude_post_ids
 * [https://webberzone.com/support/knowledgebase/contextual-related-posts-shortcode/](https://webberzone.com/support/knowledgebase/contextual-related-posts-shortcode/)
 *  Thread Starter [mx5gr](https://wordpress.org/support/users/mx5gr/)
 * (@mx5gr)
 * [5 years, 7 months ago](https://wordpress.org/support/topic/exclude-not-working-when-function-included-manually/#post-13572730)
 * Thank you for the information.
 * I have devised an external (i.e. outside the crp function) control of the IDs
   at the moment.
 * Thus, the exclusion settings etc as defined within the plugin’s GUI are only 
   enforced when the CRP plugin automatically inserts posts within the assigned 
   post types. In the case that it is manually added within a template as mentioned
   before, then all exclusions should be performed by hand.
 *  Plugin Author [Ajay](https://wordpress.org/support/users/ajay/)
 * (@ajay)
 * [5 years, 7 months ago](https://wordpress.org/support/topic/exclude-not-working-when-function-included-manually/#post-13584936)
 * Thanks – I am confused. What is the full piece of code and implementation that
   you’ve done?
 * If you’re using echo_crp you can pass an array of arguments:
 * [https://github.com/WebberZone/contextual-related-posts/blob/v2.9.4/includes/content.php#L198](https://github.com/WebberZone/contextual-related-posts/blob/v2.9.4/includes/content.php#L198)
 *  Thread Starter [mx5gr](https://wordpress.org/support/users/mx5gr/)
 * (@mx5gr)
 * [5 years, 7 months ago](https://wordpress.org/support/topic/exclude-not-working-when-function-included-manually/#post-13586368)
 * Hello,
 * Yes, understood about the arguments, that’s the way to do it currently. I was
   just referring to whether the function echo_crp could be called as echo_crp()(
   i.e. without arguments) and the function would respect the settings entered within
   the GUI.
 * Both the function arguments method and our own method have the drawback that 
   someone should go to the template by hand and make the desired changes (e.g. 
   add/remove an exclusion post ID), whereas the GUI way is more accessible and 
   requires no template alteration.
 *  Plugin Author [Ajay](https://wordpress.org/support/users/ajay/)
 * (@ajay)
 * [5 years, 7 months ago](https://wordpress.org/support/topic/exclude-not-working-when-function-included-manually/#post-13643353)
 * Oh yes of course. If you don’t pass any arguments to the function, it takes the
   ones from the global settings. The passed arguments override the global settings
   for that finer degree of control.
    Same for the shortcode.
 *  Thread Starter [mx5gr](https://wordpress.org/support/users/mx5gr/)
 * (@mx5gr)
 * [5 years, 7 months ago](https://wordpress.org/support/topic/exclude-not-working-when-function-included-manually/#post-13643406)
 * Hi Ajay,
 * Unfortunately I found out that this is not the case. That is, whatever parameters
   I have entered through the GUI (e.g. excluded content IDs) are ignored if I add
   the function without any arguments…
 *  Plugin Author [Ajay](https://wordpress.org/support/users/ajay/)
 * (@ajay)
 * [5 years, 7 months ago](https://wordpress.org/support/topic/exclude-not-working-when-function-included-manually/#post-13643659)
 * That is very strange. I’ll do some testing at my end when I get a moment.
 * Are you able to install Query Monitor to run a few tests on what queries get 
   run when you just use the function?
 * Also, would be good to see what the settings page looks like.

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Exclude not working when function included manually’ is closed to new
replies.

 * ![](https://ps.w.org/contextual-related-posts/assets/icon-256x256.png?rev=2985705)
 * [Contextual Related Posts](https://wordpress.org/plugins/contextual-related-posts/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/contextual-related-posts/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/contextual-related-posts/)
 * [Active Topics](https://wordpress.org/support/plugin/contextual-related-posts/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/contextual-related-posts/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/contextual-related-posts/reviews/)

 * 7 replies
 * 2 participants
 * Last reply from: [Ajay](https://wordpress.org/support/users/ajay/)
 * Last activity: [5 years, 7 months ago](https://wordpress.org/support/topic/exclude-not-working-when-function-included-manually/#post-13643659)
 * Status: not resolved