How can I replace the menu in my wordpress theme with a different div - but only on a certain page of my site?
Here's what it says in themes.php
<div class="frame">
<?php wp_nav_menu( array( 'theme_location' => 'menu-main','sort_column' => 'menu_order', 'menu_id' => 'main-nav-menu', 'fallback_cb' => false ) ); ?>
</div>
I need something to say instead something like:
<div class="frame">
//if the page id=1545, then show this div:
<div id="my-new-div">Slogan goes here</div>
//else
<?php wp_nav_menu( array( 'theme_location' => 'menu-main','sort_column' => 'menu_order', 'menu_id' => 'main-nav-menu', 'fallback_cb' => false ) ); ?>
</div>
Thanks in advance!!
This should get the job done:
<?php $page_object = get_queried_object();
$page_id = get_queried_object_id(); ?>
<div class="frame">
<?php if ($page_id == 1545): ?>
<div id="my-new-div">Slogan goes here</div>
<?php else: ?>
<?php wp_nav_menu( array( 'theme_location' => 'menu-main','sort_column' => 'menu_order', 'menu_id' => 'main-nav-menu', 'fallback_cb' => false ) ); ?>
<?php endif; ?>
</div>
Fixed a small issue with the php tags
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.