Skip to content

Commit

Permalink
Check if postid is set
Browse files Browse the repository at this point in the history
  • Loading branch information
ajaydsouza committed Apr 9, 2024
1 parent 0e8c65b commit 9bbaa44
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions includes/frontend/class-display.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ public static function related_posts( $args = array() ) {
*
* @since 2.9.0
*
* @param bool $short_circuit Short circuit filter.
* @param object $post Current Post object.
* @param array $args Arguments array.
* @param bool $short_circuit Short circuit filter.
* @param \WP_Post $post Current Post object.
* @param array $args Arguments array.
*/
$short_circuit = apply_filters( 'get_crp_short_circuit', $short_circuit, $post, $args );

Expand Down Expand Up @@ -119,7 +119,7 @@ public static function related_posts( $args = array() ) {
$results = self::get_posts(
array_merge(
array(
'postid' => $post->ID,
'postid' => isset( $args['postid'] ) ? $args['postid'] : $post->ID,
'strict_limit' => isset( $args['strict_limit'] ) ? $args['strict_limit'] : true,
),
$args
Expand Down Expand Up @@ -276,22 +276,14 @@ public static function related_posts( $args = array() ) {
*
* The defaults are as follows:
*
* @since 1.8.6
* @since 3.0.0 Parameters have been dropped for a single $args parameter.
* @since 3.5.0
*
* @see CRP_Query::prepare_query_args()
*
* @param array $args Optional. Arguments to retrieve posts. See WP_Query::parse_query() for all available arguments.
* @return \WP_Post[]|int[] Array of post objects or post IDs.
*/
public static function get_posts( $args = array() ) {
// Backcompat if postid was passed in the pre-3.0.0 version.
if ( is_int( $args ) ) {
$args = array(
'postid' => $args,
);
}

$get_crp_posts = new \CRP_Query( $args );

/**
Expand Down

0 comments on commit 9bbaa44

Please sign in to comment.