I had a pre_get_posts
. What I missed was this:
&& $wp_query->is_main_query()
This prevents the pre_get_posts
to run on the menu query.
Full code
add_action("pre_get_posts", "custom_front_page");
function custom_front_page( $wp_query ){
if( is_admin() ) {
return;
}
if( is_front_page() && $wp_query->is_main_query() ) {
$wp_query->set('post_type', 'produkt');
$wp_query->set('page_id', '');
$wp_query->is_page = 0;
$wp_query->is_singular = 0;
$wp_query->is_post_type_archive = 1;
$wp_query->is_archive = 1;
}
}
Related Posts:
- Return only top-level navigation items from a menu using wp_get_nav_menu_items
- Is there a way to add a class to non current menu item?
- Why does the ‘wp_nav_menu’ function work only until a menu is created?
- Functions php shortcode for displaying main menu with no child items
- Nav menus all outputting the same links
- wp_nav_walker that interacts with widgets to setup mega menu
- Why don’t ‘wp_nav_menu’ CSS classes work until a menu is created?
- ACF not showing
- How to customize the_archive_title()? Cannot figure out how to change the value it produces [duplicate]
- Control the srcset much more (not all sizes in it each time)
- Check if the image size is available and if not use ‘full’ image size
- Way to store featured image width and height in two separate variables?
- Remove Custuomize Sections
- Can we create our own theme’s function.php?
- Define PHP variable from a seperate API if statement
- How do I hook into the container of wp_nav_menu?
- Excerpt for pages not showing
- get_pages() Returns Only One Item
- Some questions about how proper add 2 CSS file in a WordPress theme?
- New custom menu created. how to apply it?
- Dropline menus — seperators between children only?
- Filter nav menu items HTML tags and wrap inner text with span
- Does size of a theme’s functions.php file matter?
- retrieves menu and converts it to a readable array
- get_next_posts_link() returns no result despite available posts
- Secondary Menu and Logged In Users
- Change menu based on page template via functions.php
- PHP 7.1 | Warning: A non-numeric value encountered in
- Show some menu sub items as dropdown under a menu item
- How to add custom li item to wordpress menu
- How to insert class in each list of categories?
- Add Login/Logout Menu Item to Primary Nav “My Account” Submenu [Woocommerce] [closed]
- I can’t add CSS with functions.php
- Getting the teaser text without overriding global variables
- Default Nav Highlight
- Combine two active_callbacks into one on theme customizer
- why is this function firing on all child menu items as well?
- WP Customizer API loaded into functions.php
- call_user_func_array() expects parameter 1 to be a valid callback, function
- why can’t i add front.css to my frontpage.php
- Different methods of adding menu support to custom theme
- “options.php” not found
- Adding a section in line at the end of the main navigation menu in php
- How to store a number (coming from cookie) into query vars for later usage in other filters?
- How to add aria role and schema markup to custom walker container
- Multiple navigation menu in same location
- Is this an acceptable practice for WordPress theme development?
- What is the correct way to include my new functions and scripts in WordPress?
- How to register a menu based on a ACF condition
- How to hightlight all ancestor menu items of a child page NOT displayed in menu
- Rewrite Question Mark in Post Template with URL Parameter for clean URLs
- contact form in template with jquery,validate and ajax
- current_page_item is missing inside wp_nav_menu
- search form leads to 404
- Why a SlideShow (made using JQuery FlexSlider) can’t work if I load it form functions.php but work if I load it from my footer.php file? [closed]
- Why I can’t load my JavaScripts using an hook inside my functions.php file?
- Unable to add extra elements to the main navi (wp_nav_menu_items)
- How Can I add a menu to the theme from withen the function.php file
- define css class in functions.php
- Custom Menu in Admin doesn’t change menu in browser
- How would I make a function to dynamically determine if user is logged to change navigation menu text?
- Conditional custom menu?
- wp_nav_menu displaying all pages
- Woocommerce Variable Product Dropdown for Custom Shop Template
- Warning at top of website & top menu gone
- How to display an image before title text in menu items
- How to fix Function create_function() is deprecated in / themes
- Exclude specific post from query
- Advanced method to control cache of enqueued style/script
- WordPress wp_dequeue_script remove all other scripts
- Bizarre Child Menu Issue on WP Site
- Header menu aligned right on all pages except for single-post page [closed]
- Can I use ‘Featured Image’ as a hero image and a thumbnail?
- Is_Page doesnt detect my page
- Test CDN link from function.php or wp_enqueue_script/style?
- How to customize archive widget only for cpt?
- How to automatically add counted number to navigation menu items?
- wp_title() return random number
- Why does echo on functions.php not yield result in source code?
- Combine multiple menus using the filter wp_nav_menu_items
- How to offset main query without affecting other queries and backend
- Menu and category highlighting for a single post
- WordPress Toggle Menu has stopped working
- Add meta data in head from theme
- what is `get_section()` and how to use it?
- Remove External Links from WordPress posts Using add_filter() in Theme functions.php
- How to retrieve image IDs from shortcode content?
- HowTo: Add wrapper to columns shortcode?
- How to add widget in main menu
- How to create admin ajax function for my contact form
- Class::$template_dir_path=get_template_directory();
- How to disable site title and description when custom header is uploaded on the customizer?
- Language Switch Function
- Insert menu into theme location depending on user logged in/out status
- wordpress not calling peliegro functions.php?
- Language switcher for subdomains
- How to add next height number in Order Attributes inside the Add new page. [duplicate]
- Adding custom field in menu options [duplicate]
- Load a Child Theme’s style.css just before the closing tag
- Modify sub_menu function to show pages below a specifically set page