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 supported 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

Looking for a WordPress expert?
Hire top notch developers on Codeable!

Consult an expert

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 *

Get in touch

Contact me using the details below

Marinus Klasen

Wilhelmina van Pruisenweg 35, 2595 AN Den Haag

marinus@mklasen.com
twitter.com/marinusklasen
linkedin.com/in/marinusklasen

  • GitHub
  • LinkedIn
  • Twitter

Have you read?

  • Elementor Widget UsageMarch 27, 2025
  • Programmatically showing popups with ElementorMarch 25, 2025
  • The Elementor sanitize_settings errorSeptember 12, 2024
  • Announcing.. Wooping Shop Health!June 13, 2024
  • Swiper setup when using wp-scriptsMarch 14, 2024

Copyright © 2025 ยท Marinus Klasen | Webdesign by Team Rood