• zweisteindesign

    (@zweisteindesign)


    Hello,

    We use the plugin “diviengine” to output our custom post types. However, as soon as we install relevanssi, the output of the post types no longer works correctly. The support of diviengine wrote me the following:

    So, specifically we are using post__in argument to get assigned post object.

    But Relevanssi ignore this parameter and returning all posts by “relevanssi_populate_array” function.

    Generated sql query by original query_posts function is following.

    SELECT wp_posts.* FROM wp_posts WHERE 1=1 AND wp_posts.ID IN (3547) AND wp_posts.post_type = 'autoren' AND ((wp_posts.post_status <> 'trash' AND wp_posts.post_status <> 'auto-draft')) ORDER BY wp_posts.post_date DESC

    Unfortunately, he could only help us so far. Perhaps someone here in the forum can help us?

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Mikko Saari

    (@msaari)

    Please provide more context, and assume I know absolutely nothing about Diviengine.

    Relevanssi should only take over searches. Is there are a search involved? If there’s just a query for a specific post in a specific post type, Relevanssi shouldn’t do anything. If it’s a WP_Query with a s parameter in it, then it’s possible Relevanssi takes over.

    It’s possible to block Relevanssi from hooking into specific queries. You need a function that hooks to the relevanssi_prevent_default_request and relevanssi_search_ok hooks and returns false if Relevanssi should not interfere. Here are some examples of how this works: Ultimate FAQ, Chamber Dashboard Business Directory.

    Thread Starter zweisteindesign

    (@zweisteindesign)

    We are trying to make our plugin to compatible with relevanssi, because there are some customers are using Relevanssi with our plugin.

    So, we added “relevanssi” parameter as “true” in arguments of query_posts.

    Also added the relevanssi_search_ok hook and returns true.

    But what I want to know is that why post__in arguments is not working with relevanssi plugin.

    Please let us know how to solve this problem with relevanssi compatibility.

    Plugin Author Mikko Saari

    (@msaari)

    I don’t know – post__in is among the WP_Query parameters Relevanssi supports. If you filter the Relevanssi search parameter array with relevanssi_search_params, that should show the post__in value in $params['post_query']. Does it?

    Thread Starter zweisteindesign

    (@zweisteindesign)

    That was the answer from support. Hope that helps you.

    I found an issue with relevanssi plugin regarding to the post__in and post__not_in parameters.

    We used both of post__in and post__not_in params in our query.

    But your plugin ignored post__in parameter when post__not_in is provided.

    Here is your plugin code about this (/lib/search.php line 1059~1071).

    $post_query = array(); if ( isset( $query->query_vars['p'] ) && $query->query_vars['p'] ) { $post_query = array( 'in' => array( $query->query_vars['p'] ) ); } if ( isset( $query->query_vars['page_id'] ) && $query->query_vars['page_id'] ) { $post_query = array( 'in' => array( $query->query_vars['page_id'] ) ); } if ( isset( $query->query_vars['post__in'] ) && is_array( $query->query_vars['post__in'] ) && ! empty( $query->query_vars['post__in'] ) ) { $post_query = array( 'in' => $query->query_vars['post__in'] ); } if ( isset( $query->query_vars['post__not_in'] ) && is_array( $query->query_vars['post__not_in'] ) && ! empty( $query->query_vars['post__not_in'] ) ) { $post_query = array( 'not in' => $query->query_vars['post__not_in'] ); }

    As you can see if post__not_in is provided, $post_query has changed to have “not in” variable only.

    If I change line 1070 like the following, it works.

    // $post_query = array( 'not in' => $query->query_vars['post__not_in'] ); $post_query['not in'] = $query->query_vars['post__not_in'];

    Please check this and hope you fix it on your side.

    And this issue is same for $parent_query as well.

    Plugin Author Mikko Saari

    (@msaari)

    Yes, I see it’s not possible to use post__in and post__not_in at the same time. That’s an old bug, but it hasn’t come up, because these parameters are very rarely used in searches, especially together.

    I’ll fix this in the next version. The hot fix described above fixes this until that.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘post__in argument to get assigned post object’ is closed to new replies.