• 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

    (@ajay)

    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/

    Thread Starter mx5gr

    (@mx5gr)

    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

    (@ajay)

    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

    Thread Starter mx5gr

    (@mx5gr)

    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

    (@ajay)

    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

    (@mx5gr)

    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

    (@ajay)

    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.