WebberZone / contextual-related-posts

Contextual Related Posts WordPress plugin
https://webberzone.com/plugins/contextual-related-posts/
39 stars 22 forks source link

Cannot override postid when using echo_crp #178

Closed thecodeassassin closed 1 year ago

thecodeassassin commented 1 year ago

Describe the bug We cannot override the postid (post for which the related posts are rendered) because of the following code:

        array_merge(
            $args,
            array(
                'postid'       => $post->ID,
                'strict_limit' => isset( $args['strict_limit'] ) ? $args['strict_limit'] : true,
            )
        )
    );

in main_query.php line 87.

Because of the order of array_merge the postid will always be overridden. Right now we need to override the global $post variable which is far from ideal.

To Reproduce Steps to reproduce the behavior: Simply use echo_crp and try to pass postid as an argument.

Expected behavior Allow postid to be passed as an argument to echo_crp.

Tested on the latest version