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?
- Issues with title-tag and document_title_parts
- Get menu object from theme_location
- Display random categories on the front page (Finding and Editing Theme Functions)
- Remove Container Element From wp_nav_menu() Markup
- How to get woocommerce inventory status [closed]
- How to use get_template_directory_uri() to load an image that is in a sub-folder of my theme?
- How to target specific wp_nav_menu in function?
- Breadcrumbs showing Parent and Child Pages
- Organize functions.php
- How to override functions.php in child theme?
- How to activate “Description” metabox for menu item programmatically?
- Dynamically add sub-categories to any category in the menu
- Change parent theme file function in child themes functions.php
- Breadcrumb how i can display page title with parent > child title with permalink ? any Idea
- Two different menus for two different locations?
- automatically adding submenu items
- Unregister Nav Menu with fallback?
- Displaying Widgets
- How to programmatically set a menu to be the Primary Menu?
- Dequeue script in template isn’t working
- Changing itemprop from logo to image on custom logo?
- Make menu structure match page heirarchy on page parent change
- Overwrite Parent Theme add_image_size in Child Theme
- Show excerpt for only first post in query
- How to add css class to image attached in all the posts?
- How to call custom function from functions.php in site-wide template files?
- Menu fallback “menu_class” rendering a “div” instead of a “ul”
- How To Remove Duplicate Menu Locations
- Where do I add html code to the menu div?
- How to enable template page only for a post id page
- How do I create page navigation linking to each H2 within the page? [closed]
- Add caption functionality to custom WordPress theme
- How to add nav menu items to a specific position within a menu
- Best practices regarding the creation of custom widgets?
- Custom Nav Walker sub-menu
- admin-ajax.php + load-scripts.php hanging for minutes
- enqueue styles for only mobile wp
- Replace a menu with widget or a custom template file programmatically
- Unique sequential reservation code
- Categories as main menu items and subcategories as nested lists
- Removing specific menu items?
- Redirect to another page using contact form 7? [closed]
- 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)
- 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?
- retrieves menu and converts it to a readable array
- Getting the teaser text without overriding global variables
- Default Nav Highlight
- why is this function firing on all child menu items as well?
- why can’t i add front.css to my frontpage.php
- Different methods of adding menu support to custom theme
- “options.php” not found
- How to add aria role and schema markup to custom walker container
- Multiple navigation menu in same location
- contact form in template with jquery,validate and ajax
- current_page_item is missing inside wp_nav_menu
- 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)
- Custom Menu in Admin doesn’t change menu in browser
- 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
- 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]
- How to automatically add counted number to navigation menu items?
- Why does echo on functions.php not yield result in source code?
- Menu and category highlighting for a single post
- WordPress Toggle Menu has stopped working
- Remove External Links from WordPress posts Using add_filter() in Theme functions.php
- How to retrieve image IDs from shortcode content?
- How to add widget in main menu
- Class::$template_dir_path=get_template_directory();
- Language Switch Function
- 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]
- Modify sub_menu function to show pages below a specifically set page
- Allow tags and attributes in post and pages content
- How to add a class name to the ancestor of a post?
- Function Reference for custom link in Admin Menu Management Page
- Add custom css to theme
- How to get postId from the argument $block when register_block_type()?
- WordPress is adding pagination for all pages not only for blog page, How to remove pagination for all pages except blog/posts page?
- Call wordpress function through functions.php when pressing menu
- How to add more than one menu for logged in members?
- Setcookie not setting cookies anywhere except admin