• Resolved FAKTOR VIER

    (@faktorvier)


    I don’t know if this is a bug or whats the correct way to do it, but we have a website that has a search that uses get_posts. The search includes both, translatable custom post types and untranslatable post types. If we just use get_posts then the untranslated post types are completely ignored and only posts from the current language are displayed.

    Is there a way to get both, posts from the current language AND untranslated posts in the same get_posts? Is there an official way to do this? We use similiar get_posts to this:

    get_posts([
      'post_type' => 'any',
      's' => 'searchterm'
    ])

    We have a temporary workaround, we just added

    'lang' => ''

    to the get_posts and removed all posts from other languages from the results. Not optimal.

    Is there a better way to do this correctly?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Chouby

    (@chouby)

    Hello,

    This is indeed a limitation of WP_Query. The language is a taxonomy. And currently, the taxonomies are globally added to the query, for all post types. You can’t create a WP_Query with taxonomies (ex the language) which would apply to some post types (translatable) and not other post types (not translatable).

    Thread Starter FAKTOR VIER

    (@faktorvier)

    Hi @chouby

    Thanks for clearing that up!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Translated and untranslated post types in the same get_posts’ is closed to new replies.