Search doesn't return CPTs when Polylang is activated

When Polylang, a free multilanguage plugin, is active on this site, the search functionality ceases to return results from the custom post type of 'usp_post'. This is a post type generated by the premium plugin USP Pro, which allows non-subscribed visitors to the site to submit posts.

I have proven to my satisfaction that Polylang is the issue here, because all I need to do is deactivate it in order for the search results to include CPTs again.

I have done quite a bit of Googling about this issue. One solution I tried was to add a function that is supposed to include all custom post types in searches. This works when Polylang is inactive but did not work when Polylang was active:

function tgm_io_cpt_search( $query ) {

    if ( $query->is_search ) {
	$query->set( 'post_type', array( 'post', 'page', 'usp_post') );

    return $query;


I also installed the Relevanssi plugin, which in the past has always worked for me. Again, CPTs are not returned when Polylang is active but show up when it is deactivated.

Finally, I've tried creating my own customized version of search.php and searchform.php, since apparently the way these are set up can affect returns, but these had no effect or else broke search completely.

This is a beta site, so I am not too concerned about damage being done. All pages are currently protected by a password except for:

I have granted access to this site's admin side through the support panel. Feel free to activate and deactivate Polylang as needed.

  • Dimitris
    • Support Star

    Hey there William Kowalski,

    I trust you're doing good today! :slight_smile:

    I just tried to replicate this in my end using the custom post types coming from MarketPress plugin with no avail! :thinking:

    Are the only custom post types that doesn't displayed from USP Pro plugin? Any chance that you've contacted them about this issue?

    I can see that you tried a workaround like in this link
    Have you tried to experiment with the action hook's priority?
    You could try to replace add_action( 'pre_get_posts', 'rc_add_cpts_to_search' ); with
    add_action( 'pre_get_posts', 'rc_add_cpts_to_search', 9999 ); in previous example and see if that makes any difference.

    Warm regards,

  • William Kowalski
    • The Crimson Coder

    Hi Dimitris
    Thanks for trying. After the feedback I got in my other thread, I decided to buy WPML, and the search feature seems to be working fine with that installed. I will likely also benefit from their support features, so I think that will probably just make everyone's life easier... yours and mine! Thanks for your help anyway.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.