-
AuthorPosts
-
May 4, 2023 at 4:44 pm #1406460
We’re using the blog post element in the layout builder. It shows the blog posts, but also posts from a custom post type. How to filter these out?
May 5, 2023 at 5:01 am #1406499Hey bonsaimedia,
Thank you for the inquiry.
What is the name of the custom post type (cpt)? You should be able to exclude items from the cpt by adding this code in the functions.php file.
function avia_post_slide_query_mod($query, $params) { foreach($query['post_type'] as $key => $value) { if( $value == 'custom-post-type-name' ) { unset($query['post_type'][$key]); } } return $query; } add_filter('avia_post_slide_query', 'avia_post_slide_query_mod', 10, 2);Just replace the placeholder (custom-post-type-name) with the actual name or slug of the custom post type.
Best regards,
IsmaelOctober 26, 2023 at 11:16 am #1423762i think ismaels code should work.
on looking for this from docu:

click on your CPT on dashboard and look to the url window on top – what post-type you see there
f.e. on portfolio ( which is a CPT too ). you see: edit.php?post_type=portfolio
try a shortform – then with the info you get from that url window
add_filter("avia_post_slide_query", function($query) { unset($query["post_type"]["vacature"]); return $query; }, 10, 1);October 26, 2023 at 11:57 am #1423775Hi,
I checked and that’s right. See link below for the CMS URL But crazy enough I keep seeing that CPT tile in the blog overview.
This is how the functions code looks like now:function avia_post_slide_query_mod($query, $params) {
foreach($query[‘post_type’] as $key => $value) {
if( $value == ‘vacature’ ) {
unset($query[‘post_type’][$key]);
}
}return $query;
}
add_filter(‘avia_post_slide_query’, ‘avia_post_slide_query_mod’, 10, 2);-
This reply was modified 2 years ago by
bonsaimedia.
October 27, 2023 at 2:34 am #1423857Hi,
Please continue here: https://kriesi.at/support/topic/exclude-custom-post-type-in-blog-posts-overview/
Best regards,
Ismael -
This reply was modified 2 years ago by
-
AuthorPosts
- The topic ‘CPT in blog posts element’ is closed to new replies.
