The menu is distorted in front page if custom post type is added to the query

I use a custom post type called “produs”.
To be displayed on the first page, the following code was added in function.php:

add_action(‘pre_get_posts’, ‘filtreaza_interogarea_posturilor’);
function filtreaza_interogarea_posturilor($query) {
if (!is_admin() && !is_preview() && !$query->is_search && is_home()) {
$query->query_vars[‘post_type’] = array(‘post’, ‘produs’);
}
}

As a result, the menu on the front page is distorted, showing all “produs” type posts. Only on the front page.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer