I am stuck and trying to figure out the Problem... in WordPress site
al-hussain
now the Problem is that,
i found a menu appearing on the home, i changed my menu..but when i clicked on pages just #
was the URL of All Pages but the page Contact-us has actual link, and the menu winch i created now appears in actual position..means when i goes to contact-us page and than my created menu is activated else,the default or static menu is appearing... even though i delete all my created menu but on loading site it shows menu...
default Menu is
and after clicking on contact us the menu is
here is header.php main_nav_menu
<!-- Begin main nav -->
<div id="nav_wrapper">
<div class="nav_wrapper_inner">
<div id="menu_border_wrapper">
<?php
if ( has_nav_menu( 'primary-menu' ) )
{
//Get page nav
wp_nav_menu(
array(
'menu_id' => 'main_menu',
'menu_class' => 'nav',
'theme_location' => 'primary-menu',
)
);
}
else
{
echo '<div class="notice">Please setup "Main Menu" using Wordpress Dashboard > Appearance > Menus</div>';
}
?>
</div>
</div>
</div>
any one can figure out ! please
Did you check your header.php file? I believe you have static menu there.
Here is the syntax to create a menu that you have created at the backend
<?php wp_nav_menu( array('menu' => 'main_menu', 'container' => '') ); ?>
Replace your static menu with the code above with the name changed in the 'menu' parameter
i sloved the Problem by Deleting the Cache, here i found directory
wp-content/cache/supercache/
thanks
Related
The whole project can be found here Github.
I added a dynamic menu on my navigation bar placed in the header. For some reason I can't figure out how to link the dynamic menu with either a class or an ID defined in my style.css file.
For some reason, neither the 'menu_class' or the 'menu_id' seem to work.
Here the menu in the header.php file:
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<!--Container of my link that are on the far right, they collapse with a small screen-->
<ul class="nav navbar-nav navbar-right">
<!--This code inject the dynamic menu inside thge av bar-->
<!-- The Dynamic menu is managed in the admin section of word press-->
<?php
wp_nav_menu(
array(
/*must have this link to function.php
*In function.php we defined this menu 'alphamenu'*/
'theme_location' => 'top-right-menu',
/*this line of code removes the default menu appearence*/
'container' => false,
/*this line makes the menu with the same layout specified above
*(same as link 1 and 2)*/
'items_wrap' => '%3$s',
/*CSS class applied to the menu*/
'menu_class' => 'nav navbar-nav custom-head-foot',
'menu_id' => 'custom-dynamic-menu'
)
);
?>
</ul> <!--dynamic menu unordered list-->
</div> <!--dynamic menu div-->
The function.php file:
/*Function to register a custom menu for the admin section
*This resurces was taken from the wordpress codex*/
function custom_theme_setup() {
/*Registered a custom primary navigation menu*/
register_nav_menus (
array( 'alphamenu', __( 'Primary Menu 123') )
);
/*Add theme support for title tag*/
add_theme_support( 'title-tag' );
}
/*Hooking in the function "custom_theme_setup()" after the theme is setup
*surce: wordpress plugin api hooks*/
add_action( 'after_setup_theme', 'custom_theme_setup');
If the render method is screwed up you can always use .nav > div with or without pseudo-class like :nth-of-type(1) or there's second way: .nav:nth-child(1) as query for first child inside div.nav?
If you want to add class, try to add it within wp_nav_menu() you wrote like this:
wp_nav_menu(
array(
/*must have this link to function.php
*In function.php we defined this menu 'alphamenu'*/
'theme_location' => 'top-right-menu',
/*this line of code removes the default menu appearence*/
'container' => false,
/*this line makes the menu with the same layout specified above
*(same as link 1 and 2)*/
'items_wrap' => '%3$s',
/*CSS class applied to the menu*/
'menu_class' => 'nav navbar-nav custom-head-foot **add_your_class_within_single_quotes**',
'menu_id' => 'custom-dynamic-menu'
)
);
or you can apply selectors I wrote in first answer to your CSS.
I am currently going through Wordpress tutorials.
The pages that I have created here are all in Capatalized case (e.g. About us). During run-time I want them to automatically convert to upper-case (i.e. ABOUT US) instead of changing the page titles through the dashboard.
I am aware about the php's strtoupper() method however not sure where to apply this so that it dynamically changes the page titles to upper-case in the nav menu.
CODE in header.php:
<!-- Nav Menu -->
<nav class="site-nav clearfix">
<?php
$args = array(
'theme_location' => 'primary'
);
wp_nav_menu( $args ); enter code here
?>
</nav>
This code in the stylesheet should work:
nav.site-nav li {
text-transform: uppercase;
}
I'm on my way to build my first Wordpress theme. Now I hit a problem with my menu. It is shown in the source code, but not on the website.
My code in the functions.php
function register_theme_menus() {
register_nav_menus(
array(
'primary-menu' => __( 'Primary Menu' )
)
);
}
add_action( 'init', 'register_theme_menus' );
My code in the header-php
<?php
$defaults = array(
'container' => false,
'theme_location' => 'primary-menu',
'menu_class' => 'no-bullet'
);
wp_nav_menu( $defaults );
?>
What's wrong here. Any ideas?
Thanks!
Try this page:
https://teamtreehouse.com/community/menu-not-appearing
I also found this page that mentions some context: https://codex.wordpress.org/Function_Reference/register_nav_menus
wp-includes/nav-menu.php
There seems to be a few pages coming into play, so you might be just missing quick edit. I have a good feeling about that first URL though. It mentions fix for very similar if not same issue.
Your Menu is registered as of what it shows in view-source but your toggle button is not working, as your toggle button is not linked with the menu so it just refreshed the page.
Your toggle button link is like this:
<span></span>Menu
So the href link for toggle button is blank.
Check following link to know how toggle button works:
https://codepen.io/CreativeJuiz/pen/oCBxz
EDIT:
Add your <nav> tag below the h1 tag
Use the below Jquery javascript code, I just tested localy your index page and worked fine for me
<script type="text/javascript">
jQuery(".nav-toggle").click(function(event) {
jQuery("nav").toggle('in');
});
</script>
Please change your toggle code because href="" is empty you must provide a #
<a class="nav-toggle" href=""><span></span>Menu</a>
with
<a class="nav-toggle" href="#"><span></span>Menu</a>
DEMO
I am developing a single page site within WordPress, that contains multiple sections. These sections are pages in WordPress. Than I loop with a custom loop through all pages and display them inside my index.php file:
<?php
$args = array('post_type' => 'page', 'orderby' => 'menu_order', 'posts_per_page' => -1);
$loop = new WP_Query($args);
?>
<?php if ($loop) : while ($loop->have_posts()) : $loop->the_post(); ?>
<?php $slides = get_field('flexslider'); ?>
<?php
if ($slides) {
get_template_part( 'templates/slideshow' );
} else {
get_template_part( 'templates/parallax' );
}
?>
<?php endwhile; ?>
<?php endif; ?>
MENU
There are two things where I am stuck at. The first one, is that I make use of wp_nav_menu to generate a menu on the page. This is working correct, but because I make use of one single page, that contains all the pages in it, I don't need to link each page with the external links to each page. I would like to replace it with hashtag (#)slug, so it will be navigate to the right section on the page. The slug should be the same as the slug of the created page.
At the moment my menu looks like this:
<?php wp_nav_menu( array(
'theme_location' => 'primary-menu',
'menu' => 'primary-menu',
'container' => 'nav',
'container_id' => 'primary-navwrapper',
'menu_id' => 'listnav'
));
?>
Beside this, I would like to use the menu order that can be ranking inside "appearance > menu" to position the sections (pages) on the right place. To do this I make use of the menu_order inside the loop that walk through all pages, so above method should work for this solution, because I want to give the clients the possibility to easily position the section on the page by simple drag and drop the menu in the right place, with one handling.
Hi im a web dev an im trying to get word press to use a 2nd navigation for my blog section. i have the main site all set up but what i want is when i hit the blog in my top nav to show a differnt navigation for the blog section. i have tried using the following code in the header.php
<?php
if (is_single('blog')){
wp_nav_menu(array('menu'=>'secondary' ));
}
?>
but this code does not seem to work even though the theme supports 2 navigations.
<nav class="Seo-nav">
<div class="Seo-nav-inner">
<?php
echo theme_get_menu(array(
'source' => theme_get_option('theme_menu_source'),
'depth' => theme_get_option('theme_menu_depth'),
'menu' => 'primary-menu',
'class' => 'Seo-hmenu'
)
);
get_sidebar('nav');
?>
the above code is the code i use to call my navigation. is there any way to get a specific page or pages to show the one menu? any help on this would be great. never had to make certain pages have different navigation before so this is a new one on me.
Like was said in comments earlier, you'll need Conditional Tags. Probably for you specifically, the is_page() conditional.
<?php
if (is_page('blog')) {
// Echo this menu on the blog slug page
wp_nav_menu(array(
'theme_location' => '[name_of_menu]'
));
} else {
// Otherwise, echo this one
wp_nav_menu(array(
'theme_location' => '[name_of_main_menu]'
));
}
See the codex for the wp_nav_menu attributes. Can print out the menu other ways, that's just the one I recommend.
Depending how you blog is set up, is_page('blog') may need to be is_home(), 'blog' == get_post_type(), or some other variation.
I think you can go here two ways.
One is to only show children of current page on the second like
function show_different_nav(){
global $post;
$sec_nav=wp_list_pages("child_of=".$post->ID);
return $sec_nav;
}
now call show_different_nav() in your template.
The other way would be to write an own filter. I modified the http://wordpress.org/plugins/get-different-menus/ in this case.
add_filter( 'wp_nav_menu_items', 'get_different_custom_menu_item_according_to_page_slug', 10, 2 );
function get_different_custom_menu_item_according_to_page_slug ( $items, $args ) {
$current_id=(int)$GLOBALS['post']->ID;
$current_slug=$GLOBALS['post']->slug;
$the_nmo = wp_get_nav_menu_object($current_slug);
if ($the_nmo==""){}else{
$menu_id=$the_nmo->term_id;
$items_2 = wp_get_nav_menu_items($menu_id);
$items="";
if ($args->theme_location == 'secondary') {
foreach ($items_2 as $item){
$link_page_id = (int)($item->object_id);
if ($current_id == $link_page_id){$cur=" current-menu-item current_page_item";}else{$cur="";
}
$items .= '<li class="menu-item menu-item-type-post_type menu-item-object-page'.$cur.'">'.$item->title.'</li>';
}
}
}
return $items;
}
In my opinion you need a menu for this called exactly the same as the page slug.