Skip to content

Commit

Permalink
Updated get_crp_posts_id()
Browse files Browse the repository at this point in the history
Fixes #163
Fixes #164
  • Loading branch information
ajaydsouza committed Apr 22, 2022
1 parent 4ce7bb0 commit b7fb18c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 5 additions & 2 deletions includes/main-query.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,13 +237,16 @@ function get_crp( $args = array() ) {
* Fetch related posts IDs.
*
* @since 1.9
* @deprecated 3.2.0
*
* @param array $args Arguments array.
* @return object $results Array of related post objects
*/
function get_crp_posts_id( $args = array() ) {
global $wpdb, $post, $crp_settings;

_deprecated_function( __FUNCTION__, '3.2.0', 'get_crp_posts' );

$crp_settings = crp_get_settings();

// Initialise some variables.
Expand Down Expand Up @@ -368,7 +371,7 @@ function get_crp_posts_id( $args = array() ) {
if ( is_int( $source_post->ID ) ) {

// Fields to return.
$fields = " $wpdb->posts.ID, $wpdb->posts.post_date ";
$fields = " $wpdb->posts.* ";

// Set order by in case of date.
if ( isset( $args['ordering'] ) && 'date' === $args['ordering'] ) {
Expand Down Expand Up @@ -426,7 +429,7 @@ function get_crp_posts_id( $args = array() ) {
$exclude_post_ids = explode( ',', $args['exclude_post_ids'] );

/** This filter has been documented in class-crp-query.php */
$exclude_post_ids = apply_filters( 'crp_exclude_post_ids', $exclude_post_ids, $args );
$exclude_post_ids = apply_filters( 'crp_exclude_post_ids', $exclude_post_ids, $args, $source_post );

// Convert it back to string.
$exclude_post_ids = implode( ',', array_filter( array_filter( $exclude_post_ids, 'absint' ) ) );
Expand Down
6 changes: 6 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,12 @@ Release post: [https://webberzone.com/blog/contextual-related-posts-v3-2-0/](htt
* Enhancements/modifications:
* If thumbnail is set as `text only`, then the style is also set as `text only` at runtime

* Bug fix:
* PHP error thrown when using `get_crp_posts_id()`

* Deprecated:
* `get_crp_posts_id()`. Use `get_crp_posts()` instead

= 3.2.0 =

* New feature:
Expand Down

0 comments on commit b7fb18c

Please sign in to comment.