Marinus Klasen

Marinus Klasen

  • Development
  • Consultancy
  • Developer Resources
  • Blog
  • Contact

July 9, 2021

Post Type missing in WP_Query or get_posts (Polylang?)

Marinus Klasen

When querying multiple post_types via get_posts, there was one specific post type that didn’t show up in combination with posts or pages. Querying only that specific post type worked fine, but the combination failed, every – single – time.

After running the same arguments in a WP_Query and checking out the SQL that it used I noticed a specific term relation was injected in the SQL string. I searched the database for this specific term and it turned out to be a language term from Polylang.

Because posts and pages are automatically translated these show up fine in the query. But the other post type was not defined as supported. But, since Polylang finds supported post type, it does customise the query so that it only returns results for the english language.

The solution was easy: Go to Polylang settings and mark the post type as a support one. Then, mark all posts in the post type as english versions.

As a result, the webinar posts now comply and all posts are showing fine!

About Marinus Klasen

Marinus has been working in software/web development for more than a decade. Since 2020 his attention shifted on sharing knowledge and developing products and tools for sharing knowledge.

Marinus Klasen on Twitter

Comments

  1. Peter says

    August 3, 2021 at 9:22 am

    Thank you very much, you saved me many hours of searching for solution to this problem!

    Reply
    • Marinus Klasen says

      August 3, 2021 at 9:24 am

      Beautiful!

      Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Ready to take action?

I'm looking forward to discuss your projects and goals!
Feel free to reach out using the contact details below.

Marinus Klasen

[email protected]
twitter.com/marinusklasen
linkedin.com/in/marinusklasen

  • GitHub
  • LinkedIn
  • Twitter

Have you read?

  • An easy way to copy code blocks from the WordPress Block EditorJune 9, 2022
  • Set a static IP for docker-compose containersMay 25, 2022
  • Justified auto width in Media Carousel Widget in ElementorMay 18, 2022
  • Using the WordPress REST APIMay 18, 2022
  • Remove all edit post links in WordPress with a simple filterMay 11, 2022

Copyright © 2022 · Marinus Klasen | Webdesign by Team Rood