CPT is simply not displayed in the main archive with “pre_get_posts”

Okay, this is what works for me, thanks to the friendly hint of Jacob Peattie: function include_custom_post_type_archives($query) { if (is_home() && empty($query->query_vars[‘suppress_filters’])) { $query->set(‘post_type’, array( ‘post’, ‘landingpages’, )); return $query; } } add_filter(‘pre_get_posts’, ‘include_custom_post_type_archives’);

Exclude Custom post type from /blog page

you can try this one function exclude_some_post_type($query) { if ( ! is_admin() && $query->is_main_query() ) { if ( $query->is_search || is_home() ) { // in search page $query->set( ‘post_type’, ‘post’ ); } } } add_action( ‘pre_get_posts’, ‘exclude_some_post_type’ ); The function that applied to a pre_get_posts hook will set only default post type (post), and will … Read more

How check if a post is saved from backend or frontend?

I would add some hidden input field to frontend form, and check for its presence in the save_post hook. … <input type=”hidden” name=”saved-on-frontend” value=”1″> … And then check for it in that hooked function: function my_save_hook() { if( isset( $_POST[‘saved-on-frontend’] ) ) { return; // don’t do anything … } } add_action( ‘save_post_CUSTOM_POST_TYPE’, ‘my_save_hook’ );