Display menu if site is homepage (wordpress)

if is not front page wordpress
wordpress header if homepage
front page vs homepage wordpress
wordpress show only on homepage
is_front_page() not working
wordpress if page is not
wordpress is front page
wordpress if page id

On site I have left menu, which appears on almost every subpage

<div class="category_menu">
    <nav class="cat_menu">
        <div class="menu_title parent_cat_name">
            <h6><?php echo $category->name; ?></h6>
        </div>
        <?php rs_left_menu_subcats($subcategories); ?>
    </nav>
</div>

I would like do display the another menu if site is homepage. In other cases it should be menu from code I pasted.

What code may I use?

You can combine is_front_page() and is_home() Wordpress function.

<?php if( is_front_page() && is_home() ) { ?>
    // you are on homepage, show your another menu
<?php } else { ?>
<div class="category_menu">
    <nav class="cat_menu">
        <div class="menu_title parent_cat_name">
            <h6><?php echo $category->name; ?></h6>
        </div>
        <?php rs_left_menu_subcats($subcategories); ?>
    </nav>
</div>
<?php } ?>

WordPress Front Page vs Homepage, (is_front_page). You can define such behaviour in Settings=> Reading. In your plugin or theme, you may use this functions to display or change contents depending on user settings. Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information. Display menu if site is homepage (wordpress) Ask

If you want to display specific content on wordpress homepage than you can do it using is_front_page()

if ( is_front_page() ) {    
    // your menu code goes here for home page
}

Tip: is_home() vs is_front_page(), How do you set a page as your homepage in WordPress? If Menu is broken, no visibility rules are available There’s a known limitation with adding functionality for menu items in WordPress, and conflicts may happen between some plugins and themes. If there are multiple plugins that extend Menu Items, for example If Menu and a plugin for Menu Icons, only one of them can add the needed

Variant with php -- answer by @hardik solanki

Variant with CSS:

.home .category_menu { display: block; } 

How to Set A Page As Homepage – WordPress Tutorials for Beginners, Display tailored menu items to each visitor with visibility rules. show if User is logged in AND Device is mobile; show if User is Admin AND Is front page. Head over to the Reading settings menu (Settings > Reading), and locate the first setting called, Front page displays . Select the second option, and you’ll get access to two dropdown menus. The first option will let you select the page you want displayed on your homepage.

Since is_front_page() and is_home() for me doesn't work (WP 5.2.3), I write this condition:

global $wp;  
$current_url = home_url(add_query_arg(array($_GET), $wp->request));
if ($current_url==get_site_url()) { 
    // code for homepage 
}

How to Add Custom Navigation Menus in WordPress Themes, Instead of using sidebar widgets to tell on what page they should be visible, I like to choose at the menu settings to appear on specific pages. Default Wordpress  When WordPress 3.0 was launched, many people did not know about how to add a home page link in the WordPress 3.0 Menu. The simple solution was to add home-page link as a Custom Link to the menu. Well in this article, we will show you how you can show home page link under the pages widget in WordPress 3.0 menu system.

is_front_page() | Function, A static home page is like customizing the front door to your site. By default, your home Page (Optional) · 4: Create a Custom Menu The preview window will display your newly selected page as the front page of your site. Click on the Save​  In this final step, we’ll configure WordPress to display our static page as the homepage. We’ll also tell WordPress to display our blog posts on the placeholder Blog page we created in step 2. To set the static front page and the blog page: Click on Settings >> Reading in your admin dashboard. Set Your homepage displays to A static page.

If Menu – Visibility control for Menu Items – WordPress plugin , By default the front page of new WordPress.com sites will display posts from your Also, if you have a theme that supports the Custom Menus Feature you can:. By default, WordPress adds all the published pages to the menu automatically. However, customization of menu is possible, such as adding a link to a category or to external site, changing the order of the menu link, or creating a sub-menu. The Appearance Menu Screen is accessible via Dashboard > Appearance > Menus. Screen Options # Screen Options

How can I display a menu on certain pages only?, Site Menus are a list of links that are usually displayed as the main navigation for your site. The menu location can vary depending on your theme, and some  The blog homepage is the page that shows the time-based blog content of the site. is_home() is dependent on the site’s "Front page displays" Reading Settings ‘show_on_front’ and ‘page_for_posts’. If a static page is set for the front page of the site, this function will return true only on the page you set as the "Posts page".

Comments
  • Looks good, but after use it I don't see no additional menu. I try with only "test" text too and it is also invisible.
  • @Pat and in Wordpress administration, which site you using as homepage? Standard WP page with posts, or some static page?
  • I use static page.
  • Then use only is_front_page() in the conditional, so first line of my code must be: <?php if( is_front_page() ) { ?>