{"id":699,"date":"2021-07-09T09:49:26","date_gmt":"2021-07-09T09:49:26","guid":{"rendered":"https:\/\/mklasen.com\/?p=699"},"modified":"2022-07-25T09:59:39","modified_gmt":"2022-07-25T09:59:39","slug":"post-type-missing-in-wp_query-or-get_posts-polylang","status":"publish","type":"post","link":"https:\/\/mklasen.com\/post-type-missing-in-wp_query-or-get_posts-polylang\/","title":{"rendered":"Post Type missing in WP_Query or get_posts (Polylang?)"},"content":{"rendered":"\n

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.<\/p>\n\n\n\n

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.<\/p>\n\n\n\n

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.<\/p>\n\n\n\n

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.<\/p>\n\n\n\n

As a result, the webinar posts now comply and all posts are showing fine!<\/p>\n","protected":false},"excerpt":{"rendered":"

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 […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_genesis_hide_title":false,"_genesis_hide_breadcrumbs":false,"_genesis_hide_singular_image":false,"_genesis_hide_footer_widgets":false,"_genesis_custom_body_class":"","_genesis_custom_post_class":"","_genesis_layout":"","footnotes":""},"categories":[1],"tags":[],"acf":[],"yoast_head":"\nPost Type missing in WP_Query or get_posts (Polylang?) - Marinus Klasen<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/mklasen.com\/post-type-missing-in-wp_query-or-get_posts-polylang\/\" \/>\n<meta property=\"og:locale\" content=\"nl_NL\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Post Type missing in WP_Query or get_posts (Polylang?) - Marinus Klasen\" \/>\n<meta property=\"og:description\" content=\"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 […]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/mklasen.com\/post-type-missing-in-wp_query-or-get_posts-polylang\/\" \/>\n<meta property=\"og:site_name\" content=\"Marinus Klasen\" \/>\n<meta property=\"article:publisher\" content=\"http:\/\/facebook.com\/marinus.klasen\" \/>\n<meta property=\"article:author\" content=\"http:\/\/facebook.com\/marinus.klasen\" \/>\n<meta property=\"article:published_time\" content=\"2021-07-09T09:49:26+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-07-25T09:59:39+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/mklasen.com\/content\/uploads\/2020\/03\/cropped-cropped-mklasen-logo-margin-1.png\" \/>\n\t<meta property=\"og:image:width\" content=\"512\" \/>\n\t<meta property=\"og:image:height\" content=\"512\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Marinus Klasen\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@http:\/\/twitter.com\/marinusklasen\" \/>\n<meta name=\"twitter:site\" content=\"@marinusklasen\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Marinus Klasen\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minuut\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/mklasen.com\/post-type-missing-in-wp_query-or-get_posts-polylang\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/mklasen.com\/post-type-missing-in-wp_query-or-get_posts-polylang\/\"},\"author\":{\"name\":\"Marinus Klasen\",\"@id\":\"https:\/\/mklasen.com\/#\/schema\/person\/bbad02776afb72dfba2ebfe1956a4e29\"},\"headline\":\"Post Type missing in WP_Query or get_posts (Polylang?)\",\"datePublished\":\"2021-07-09T09:49:26+00:00\",\"dateModified\":\"2022-07-25T09:59:39+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/mklasen.com\/post-type-missing-in-wp_query-or-get_posts-polylang\/\"},\"wordCount\":188,\"commentCount\":2,\"publisher\":{\"@id\":\"https:\/\/mklasen.com\/#\/schema\/person\/bbad02776afb72dfba2ebfe1956a4e29\"},\"articleSection\":[\"General\"],\"inLanguage\":\"nl-NL\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/mklasen.com\/post-type-missing-in-wp_query-or-get_posts-polylang\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/mklasen.com\/post-type-missing-in-wp_query-or-get_posts-polylang\/\",\"url\":\"https:\/\/mklasen.com\/post-type-missing-in-wp_query-or-get_posts-polylang\/\",\"name\":\"Post Type missing in WP_Query or get_posts (Polylang?) - Marinus Klasen\",\"isPartOf\":{\"@id\":\"https:\/\/mklasen.com\/#website\"},\"datePublished\":\"2021-07-09T09:49:26+00:00\",\"dateModified\":\"2022-07-25T09:59:39+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/mklasen.com\/post-type-missing-in-wp_query-or-get_posts-polylang\/#breadcrumb\"},\"inLanguage\":\"nl-NL\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/mklasen.com\/post-type-missing-in-wp_query-or-get_posts-polylang\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/mklasen.com\/post-type-missing-in-wp_query-or-get_posts-polylang\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/mklasen.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"General\",\"item\":\"https:\/\/mklasen.com\/general\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Post Type missing in WP_Query or get_posts (Polylang?)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/mklasen.com\/#website\",\"url\":\"https:\/\/mklasen.com\/\",\"name\":\"Marinus Klasen\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/mklasen.com\/#\/schema\/person\/bbad02776afb72dfba2ebfe1956a4e29\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/mklasen.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"nl-NL\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/mklasen.com\/#\/schema\/person\/bbad02776afb72dfba2ebfe1956a4e29\",\"name\":\"Marinus Klasen\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"nl-NL\",\"@id\":\"https:\/\/mklasen.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/mklasen.com\/content\/uploads\/2021\/01\/DONE1171.jpg\",\"contentUrl\":\"https:\/\/mklasen.com\/content\/uploads\/2021\/01\/DONE1171.jpg\",\"width\":1500,\"height\":1000,\"caption\":\"Marinus Klasen\"},\"logo\":{\"@id\":\"https:\/\/mklasen.com\/#\/schema\/person\/image\/\"},\"description\":\"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\",\"sameAs\":[\"http:\/\/facebook.com\/marinus.klasen\",\"https:\/\/nl.linkedin.com\/in\/marinusklasen\",\"https:\/\/twitter.com\/http:\/\/twitter.com\/marinusklasen\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Post Type missing in WP_Query or get_posts (Polylang?) - Marinus Klasen","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/mklasen.com\/post-type-missing-in-wp_query-or-get_posts-polylang\/","og_locale":"nl_NL","og_type":"article","og_title":"Post Type missing in WP_Query or get_posts (Polylang?) - Marinus Klasen","og_description":"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 […]","og_url":"https:\/\/mklasen.com\/post-type-missing-in-wp_query-or-get_posts-polylang\/","og_site_name":"Marinus Klasen","article_publisher":"http:\/\/facebook.com\/marinus.klasen","article_author":"http:\/\/facebook.com\/marinus.klasen","article_published_time":"2021-07-09T09:49:26+00:00","article_modified_time":"2022-07-25T09:59:39+00:00","og_image":[{"width":512,"height":512,"url":"https:\/\/mklasen.com\/content\/uploads\/2020\/03\/cropped-cropped-mklasen-logo-margin-1.png","type":"image\/png"}],"author":"Marinus Klasen","twitter_card":"summary_large_image","twitter_creator":"@http:\/\/twitter.com\/marinusklasen","twitter_site":"@marinusklasen","twitter_misc":{"Written by":"Marinus Klasen","Est. reading time":"1 minuut"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/mklasen.com\/post-type-missing-in-wp_query-or-get_posts-polylang\/#article","isPartOf":{"@id":"https:\/\/mklasen.com\/post-type-missing-in-wp_query-or-get_posts-polylang\/"},"author":{"name":"Marinus Klasen","@id":"https:\/\/mklasen.com\/#\/schema\/person\/bbad02776afb72dfba2ebfe1956a4e29"},"headline":"Post Type missing in WP_Query or get_posts (Polylang?)","datePublished":"2021-07-09T09:49:26+00:00","dateModified":"2022-07-25T09:59:39+00:00","mainEntityOfPage":{"@id":"https:\/\/mklasen.com\/post-type-missing-in-wp_query-or-get_posts-polylang\/"},"wordCount":188,"commentCount":2,"publisher":{"@id":"https:\/\/mklasen.com\/#\/schema\/person\/bbad02776afb72dfba2ebfe1956a4e29"},"articleSection":["General"],"inLanguage":"nl-NL","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/mklasen.com\/post-type-missing-in-wp_query-or-get_posts-polylang\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/mklasen.com\/post-type-missing-in-wp_query-or-get_posts-polylang\/","url":"https:\/\/mklasen.com\/post-type-missing-in-wp_query-or-get_posts-polylang\/","name":"Post Type missing in WP_Query or get_posts (Polylang?) - Marinus Klasen","isPartOf":{"@id":"https:\/\/mklasen.com\/#website"},"datePublished":"2021-07-09T09:49:26+00:00","dateModified":"2022-07-25T09:59:39+00:00","breadcrumb":{"@id":"https:\/\/mklasen.com\/post-type-missing-in-wp_query-or-get_posts-polylang\/#breadcrumb"},"inLanguage":"nl-NL","potentialAction":[{"@type":"ReadAction","target":["https:\/\/mklasen.com\/post-type-missing-in-wp_query-or-get_posts-polylang\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/mklasen.com\/post-type-missing-in-wp_query-or-get_posts-polylang\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/mklasen.com\/"},{"@type":"ListItem","position":2,"name":"General","item":"https:\/\/mklasen.com\/general\/"},{"@type":"ListItem","position":3,"name":"Post Type missing in WP_Query or get_posts (Polylang?)"}]},{"@type":"WebSite","@id":"https:\/\/mklasen.com\/#website","url":"https:\/\/mklasen.com\/","name":"Marinus Klasen","description":"","publisher":{"@id":"https:\/\/mklasen.com\/#\/schema\/person\/bbad02776afb72dfba2ebfe1956a4e29"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/mklasen.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"nl-NL"},{"@type":["Person","Organization"],"@id":"https:\/\/mklasen.com\/#\/schema\/person\/bbad02776afb72dfba2ebfe1956a4e29","name":"Marinus Klasen","image":{"@type":"ImageObject","inLanguage":"nl-NL","@id":"https:\/\/mklasen.com\/#\/schema\/person\/image\/","url":"https:\/\/mklasen.com\/content\/uploads\/2021\/01\/DONE1171.jpg","contentUrl":"https:\/\/mklasen.com\/content\/uploads\/2021\/01\/DONE1171.jpg","width":1500,"height":1000,"caption":"Marinus Klasen"},"logo":{"@id":"https:\/\/mklasen.com\/#\/schema\/person\/image\/"},"description":"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","sameAs":["http:\/\/facebook.com\/marinus.klasen","https:\/\/nl.linkedin.com\/in\/marinusklasen","https:\/\/twitter.com\/http:\/\/twitter.com\/marinusklasen"]}]}},"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","featured_image_src":null,"featured_image_src_square":null,"author_info":{"display_name":"Marinus Klasen","author_link":"https:\/\/mklasen.com\/author\/mklasen\/"},"_links":{"self":[{"href":"https:\/\/mklasen.com\/wp-json\/wp\/v2\/posts\/699"}],"collection":[{"href":"https:\/\/mklasen.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mklasen.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mklasen.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mklasen.com\/wp-json\/wp\/v2\/comments?post=699"}],"version-history":[{"count":3,"href":"https:\/\/mklasen.com\/wp-json\/wp\/v2\/posts\/699\/revisions"}],"predecessor-version":[{"id":1193,"href":"https:\/\/mklasen.com\/wp-json\/wp\/v2\/posts\/699\/revisions\/1193"}],"wp:attachment":[{"href":"https:\/\/mklasen.com\/wp-json\/wp\/v2\/media?parent=699"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mklasen.com\/wp-json\/wp\/v2\/categories?post=699"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mklasen.com\/wp-json\/wp\/v2\/tags?post=699"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}