Title: Fetch Custom Related Posts via PHP
Last modified: August 31, 2016

---

# Fetch Custom Related Posts via PHP

 *  [elix1289](https://wordpress.org/support/users/elix1289/)
 * (@elix1289)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/fetch-custom-related-posts-via-php/)
 * Hi Folks,
 * let me thank you first for this great plugin, it is the best I have tested.
 * I am calling the script via PHP with this code:
    `<?php if ( function_exists('
   echo_ald_crp' ) ) echo_ald_crp(); ?>`
 * Is there a way to pass on custom post IDs via PHP?
 * Something like
 *     ```
       <?php
       $crp_args = array( 'SHOWTHESEPOSTS' => array(123,234,456), 'limit' => $limit );
       if ( function_exists( 'echo_ald_crp' ) ) echo_ald_crp($crp_args); ?>
       ```
   
 * ??
 * (I am trying to use custom related posts on an archive template, which is not
   registered in the database, therefore I would like to pass the custom page ids
   on via PHP.)
 * Best wishes,
    Elix
 * [https://wordpress.org/plugins/contextual-related-posts/](https://wordpress.org/plugins/contextual-related-posts/)

Viewing 1 replies (of 1 total)

 *  Plugin Author [WebberZone](https://wordpress.org/support/users/webberzone/)
 * (@webberzone)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/fetch-custom-related-posts-via-php/#post-7111219)
 * The best option is to use the API.
 * [https://gist.github.com/ajaydsouza/968b24a052e858bf8926](https://gist.github.com/ajaydsouza/968b24a052e858bf8926)
 * You’ll need to do an `array_merge` with the post IDs you want with the `$posts`
   variable

Viewing 1 replies (of 1 total)

The topic ‘Fetch Custom Related Posts via PHP’ 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/)

 * 1 reply
 * 2 participants
 * Last reply from: [WebberZone](https://wordpress.org/support/users/webberzone/)
 * Last activity: [10 years, 2 months ago](https://wordpress.org/support/topic/fetch-custom-related-posts-via-php/#post-7111219)
 * Status: not resolved