Title: [Plugin: Related Posts for WordPress] SQL error when invoking function manually (only)
Last modified: August 20, 2016

---

# [Plugin: Related Posts for WordPress] SQL error when invoking function manually (only)

 *  [Riccardo](https://wordpress.org/support/users/riccardof/)
 * (@riccardof)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/plugin-related-posts-for-wordpress-sql-error-when-invoking-function-manually-only/)
 * Hi,
    I really like the plugin, good job.
 * I am having an issue when I try to call directly the API.
    The interesting thing
   is that this error only occur when I call the API function, whereas the automatic
   hook seems to work fine, even within the same page!
 *     ```
       WordPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND wp.id = wpr.post2_id AND wp.post_status IN ('publish','private') ) AS tab1 ' at line 2]
       SELECT * FROM ( SELECT position2 as position_unified, wp.*, wpr.* FROM wpgtwp_post_relationships	wpr ,wpgtwp_posts	 wp WHERE wpr.post1_id = AND wp.id = wpr.post2_id AND wp.post_status IN ('publish','private') ) AS tab1 UNION ALL SELECT * FROM (SELECT position1 as position_unified, wp.*, wpr.* FROM wpgtwp_post_relationships	wpr ,wpgtwp_posts	 wp WHERE wpr.post2_id = AND wp.id = wpr.post1_id AND wp.post_status IN ('publish','private') ) AS tab2 ORDER BY 'position_unified' ASC, 'post_date' ASC
       ```
   
 * Any idea of what might be going on?
 * Riccardo
    [http://www.gurtip.it](http://www.gurtip.it)
 * [http://wordpress.org/extend/plugins/microkids-related-posts/](http://wordpress.org/extend/plugins/microkids-related-posts/)

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

 *  Thread Starter [Riccardo](https://wordpress.org/support/users/riccardof/)
 * (@riccardof)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/plugin-related-posts-for-wordpress-sql-error-when-invoking-function-manually-only/#post-2999078)
 * p.s. the api call I am referring to is `MRP_get_related_posts`
 *  Thread Starter [Riccardo](https://wordpress.org/support/users/riccardof/)
 * (@riccardof)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/plugin-related-posts-for-wordpress-sql-error-when-invoking-function-manually-only/#post-2999083)
 * p.p.s. forgive the pssss… I just wanted to say that I get no errors when using
   the shortcode as well.. I only have problems when I call the function directly

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

The topic ‘[Plugin: Related Posts for WordPress] SQL error when invoking function
manually (only)’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/microkids-related-posts_f6f7f5.svg)
 * [Related Posts for WordPress](https://wordpress.org/plugins/microkids-related-posts/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/microkids-related-posts/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/microkids-related-posts/)
 * [Active Topics](https://wordpress.org/support/plugin/microkids-related-posts/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/microkids-related-posts/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/microkids-related-posts/reviews/)

 * 2 replies
 * 1 participant
 * Last reply from: [Riccardo](https://wordpress.org/support/users/riccardof/)
 * Last activity: [13 years, 7 months ago](https://wordpress.org/support/topic/plugin-related-posts-for-wordpress-sql-error-when-invoking-function-manually-only/#post-2999083)
 * Status: not resolved