WordPress Custom Menu (3rd Level Nesting Issue) - php

I've ran into a problem using a custom WordPress menu that I can't seem to solve, so after doing a lot of searching the web & failing to fix this over the past few days, I've decided to see if anybody here on StackOverflow can help.
Please note: I would use a Walker function for this but I'm too far gone with the code right now and the way the design works I'm having to build the menu this way.
My snippet for my dropdown: http://pastebin.com/8Stfs90c (would post but it would crucify the screen).
I’m having trouble with the 3rd level of my dropdown menu. In this image: http://s13.postimg.org/lxhslt0lz/image.png you can see that there’s a <li></li> that I’ve highlighted (Pages, About Me, About Us). The structure is as follows
Pages (Parent)
About Me (Parent: Pages)
About Us (Parent: About Me)
And these are fine, BUT when it goes to the third dropdown, it cuts of the <li> and leaves the rest of the Pages children and puts them into a separate container and not the <li> for Pages.
So it should work like so:
Pages (Parent)
About Me (Parent: Pages)
About Us (Parent: About Me)
Right Sidebar (Parent: Pages)
Left Sidebar (Parent: Pages)
Our Process (Parent: Pages)
And all though it may look like this on the dropdown (visually), as you can see in the code it isn’t represented by this. I think the problem I’m having is the checks I’m doing for closing the </li> is wrong. I’ve had this problem for a few days and I just can't seem to fix it. I was going to post this on the WordPress based forum but it's more of a PHP error than anything else.
Here’s a quick screenshot of me hovering over the elements that should be in Pages: http://s23.postimg.org/ef4ame6m3/image.png - as you see they’re separated from the <li>.
To replicate this what I've done is just created a menu structure in WordPress and used the code that's in the snippet (basically I just pasted it into the index.php file) to show how it's being represented.
I really hope somebody can help with this as it has been driving me mad and put a holt on my project for the past few days.
Apologies for the links above, I would post them directly in (screenshots & code) but I didn't want to take away from the actual problem.
If somebody does manage to provide me with the solution I'd be more than happy to buy you a virtual coffee or two!

Out of curiosity, I could be missing the point, is there a reason why would not want to use wp_nav_menu() to handle all of this?
Ex below would output the correct structure for you to theme as your screenshot if applied in your context?
wp_nav_menu( array( 'container' => 'nav', 'container_class' => 'your-class', 'fallback_cb' => 'wp_page_menu', 'theme_location' => 'primary-menu' ) );
Thanks.

Had a quick look at the code, I suppose line 100-130 are dealing with the third dropdown. Actually whats happening is you already have an ol on line 105, then its again being called through the loop on line 122.
echo "<ol><li><a href='" . $link . "'>" . $t->title . "</a></li></ol>";
I think the problem is on line 128 you have to remove ol from the end and create a new condition just for this.
Sorry if i am not being of any help but its really hard to picture the whole code in mind without seeing it. If you are really stuck send the ftp details in chat and i can have a look.

Hi There try this css code to create multiple Nested menu create.
WP code for menu in header.php
<nav class="photoshoot-menu">
<?php wp_nav_menu(array('theme_location' => 'primary','container' => ' ')); ?>
</nav>
CSS Code Add in your style.
.photoshoot-menu {
float: right;
width: auto;
padding-left: 0px;
padding-right: 0px;
}
.photoshoot-menu ul {
padding-left: 0px;
margin: 0px;
}
.photoshoot-menu > ul li {
display: inline-block;
position: relative;
text-transform: uppercase;
margin: 3px 2px;
position: relative;
}
.photoshoot-menu > ul > li > a {
color: #212121;
display: inline-block;
padding: 8px 20px;
border: 1px solid #4f4f4f;
border-radius: 4px;
}
.photoshoot-menu > ul > li > a:hover,
.photoshoot-menu > ul > li > a:focus,
.photoshoot-menu > ul > li.current_page_item > a {
background-color: #343434;
color: #f45c06;
}
.photoshoot-menu ul ul {
border-radius: 4px;
border: 1px solid #4f4f4f;
background-color: rgba(38, 38, 38, 0.95);
opacity: 0;
position: absolute;
top: 42px;
width: 100%;
min-width: 170px;
z-index: 1;
visibility: hidden;
transition: all 0.5s ease-in-out;
-webkit-transition: all 0.5s ease-in-out;
}
.photoshoot-menu ul li:hover > ul {
opacity: 1;
visibility: visible;
}
.photoshoot-menu ul ul li {
width: 100%;
}
.photoshoot-menu ul ul li a {
display: inline-block;
line-height: 16px;
padding: 5px;
color: #FFF;
width: 100%;
}
.photoshoot-menu ul ul li a:hover,
.photoshoot-menu ul ul li a:focus {
color: #f45c06;
}
.photoshoot-menu ul ul ul {
left: 99%;
top: 0px;
}
<nav class="photoshoot-menu">
<ul class="menu" id="menu-all-pages">
<li>Home
</li>
<li>Level 1
<ul>
<li>Level 2
<ul>
<li>Level 3
<ul>
<li>Lorem Ipsum
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li>Sample Page
</li>
</ul>
</nav>

Related

Defining drop-down menu style in CSS for a Joomla template

I am trying to build a custom template from scratch for my Joomla 3.9 website. I am new to web design. I have been following several tutorials on how to set up menu style via CSS, but I cannot seem to find information on how to define the drop-down menu style. The menu items are defined in Joomla configuration, and the menu should be injected into the right place.
relevant lines from index.php:
<body>
<div class="nav">
<nav>
<jdoc:include type="modules" name="navigation" style="none"/>
</nav>
</div>
</body>
And from template.css:
.nav {
background-color:#FFA500;
position: sticky;
top: 0;
}
ul.nav { //this element needs centering
margin:auto;
width:80%;
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #FFA500;
}
ul.nav li {
float:left;
display:block;;
text-align: center;
padding: 14px 16px;
text-decoration: none;
border-right: 3px solid #bbb;
}
ul.nav li:last-child {
border-right: none;
}
ul.nav li a{
color: white;
font-size: 20px
}
ul.nav li:hover {
background-color: #e09100;
}
This code works fine for displaying the menu the way I want (except for not centering it in the screen, but that's not relevant) for simple menu items. However, if I add sub-menu items in Joomla Menu configuration, it gets all messed up. I want these sub-menus to be displayed in a drop-down fashion when the user hovers over the parent item with the mouse, but instead, right now these sub-menus are displayed below the parent item statically. Obviously, that's because I haven't written the code for that part yet.
Problem is, I do not know how to define the style for these sub-menu items, because they are not defined in the CSS, but instead, provided by Joomla. I cannot find any relevant documentation that would tell me the keywords to hook up to these items. Can someone tell me how to turn these sub-menu items into a nice drop-down menu when the user hovers the mouse over the parent menu item?

Creating a Wordpress Header

Hello guys and girls,
I've been given my first WordPress build at work, with freedom on pretty much anything. I chose to use Altitude pro as a theme with Genesis as a framework.
I love the theme but, for a service page the theme is not exactly fantastic. To spice it up a bit, I'd like to create a custom header design for every service page on the site.
This would be a coloured background over the top 1000px of the page or so, that has a solid colour with some patterns on top.
Due to my inexperience though, I'm not really sure on how to do it and my PHP knowledge is not fantastic.
Could anyone please assist?
Thanks!
You can check here for normal headers or even fixed headers. They explain well. http://www.w3schools.com/css/css_navbar.asp
Here is a code that makes a fixed header with menus. If you don't want to make it fixed you can just delete "position: fixed;".
<!DOCTYPE html>
<html>
<head>
<style>
body {margin:0;}
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333;
position: fixed;
top: 0;
width: 100%;
}
li {
float: left;
}
li a {
display: block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
li a:hover:not(.active) {
background-color: #111;
}
.active {
background-color: #4CAF50;
}
</style>
</head>
<body>
<ul>
<li><a class="active" href="#home">Home</a></li>
<li>News</li>
<li>Contact</li>
<li>About</li>
</ul>
<div style="padding:20px;margin-top:30px;background-color:#1abc9c;height:1500px;">
<h1>Fixed Top Navigation Bar</h1>
<h2>Scroll this page to see the effect</h2>
<h2>The navigation bar will stay at the top of the page while scrolling</h2>
</div>
</body>
</html>

CSS id is passing to the rest of the website

I´m trying to do a navigation menu on a website and for some reason what i defined in the id topnav_ubid is getting applied to the rest of the site, especially on a:link and a:visited. I just wanted the style to be applied to the menu. I tried wraping inside a div but still no luck. What's wrong with my code? Can someone help?
I defined this on my style.css
#topnav_ubid ul li {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
}
#topnav_ubid li {
float: left;
}
#topnav_ubid a:link, a:visited {
display: block;
width: 85px;
height: 20px;
font-weight: bold;
color: #FFFFFF;
background-color: orange;
text-align: center;
padding: 4px;
text-decoration: none;
text-transform: uppercase;
}
#topnav_ubid a:hover, a:active {
background-color: #7A991A;
And had this in HTML:
<div id="topnav_ubid">
<ul>
<li><? print $MSG_501; ?></li>
<?php
if($_SESSION["BPLowbidAuction_LOGGED_IN"]) {
/* user is logged in, give link to edit data or log out */
?>
<li class="<?=$user_menu_style;?>"><? print $MSG_622; ?></li>
<li><? print $MSG_245; ?></li>
<?php
} else {
/* user not logged in, give link to register or login */
?>
<li class="<?=$user_login_style;?>"><? print $MSG_259; ?></li>
<?php
}
?>
<li><? echo $MSG_5085 ;?></li>
<li><? echo $MSG_31_0048; ?></li>
<li> <? print $MSG_164; ?></li>
</ul>
</div>
#topnav_ubid a:link, a:visited { actually are two selectors: #topnav_ubid a:link and a:visited. The second one applies to every visited link, regardless of its parent.
I think you meant this to be #topnav_ubid a:link, #topnav_ubid a:visited {. The same mistake is made in the next selector: #topnav_ubid a:hover, a:active.
I usually add a break after a comma in a list of selectors, so it would be written as:
#topnav_ubid a:link,
#topnav_ubid a:visited {
That way, it's much easier to instantly see all the selectors and you are less likely to make this mistake.
Also note, that in your developer tools (F12) in your browser, you can inspect which styles are applied and which selector caused that. That should help you find any invalid selectors pretty easily.

MPDF57 CSS3 list-style:none not being applied (or isn't supported) for <UL> items inside <TD> element

I would like to clear list-style-type:circle; from the generated PDF (using MPDF57). I've read the CSS3 Docs (and according to the documentation, list-style:none; is supported), but during the Output() stage of creating a PDF file, the circle can seen.
HTML OUTPUT
(source: iforce.co.nz)
Border is to only emphasize, which elements are being targeted.
PDF OUTPUT
(source: iforce.co.nz)
CSS (HTML available via PasteBin).
.schedule_logo_con img {
width: 300px;
height: auto;
}
.daily_schedule { font-family: helvetica, sans serif }
.schedule {
font-family: helvetica, sans serif;
margin: 0px !important;
padding-bottom: 10px;
}
.schedule_list { margin: 10px 0 0 0 }
ul {
margin: 0;
padding: 0;
}
.weekday {
width: 65px;
text-align: center;
border-left: solid #ddd 1px;
color: red;
}
.weekday ul li {
border: 1px solid red;
}
ul, .weekday ul, .weekday ul li {
list-style-type: none;
}
I've also tried list-style-type:none; (In addition too checking MPDF56 to see whether it is something with MPDF57), but regardless this style is not being applied.
For now, it seems to be a rendition problem, from the library itself
<UL> with no parents
But, the above CSS does work, if the UL element is being generated on its own, and not as a child of a another element.
<ul>
<li>Test A</li>
<li>Test B</li>
</ul>
PDF OUTPUT
(source: iforce.co.nz)
Solution
Therefore, the designer and I have a found a work around, using divs and replicating a list with display:block;, although if someone is able to figure out a solution for <UL>, without high server load (That would be great too).
CSS
div.weekday_time {
display:block;
}
HTML
<div class='weekday_time'>
10:30 PM
</div>

IE Drop menu not working

I have a website with a css drop menu, which works fine on chrome and firefox, but in IE the drop menu doesn't display.... it's almost like it doesn't exist at all...
I've tried multiple times to copy some code or menus from other sites i have that do work in IE, but without success.
Here's the html...
<ul id="menu">
<li>INTRO |</li>
<li>HOME |</li>
<li>ACCOMMODATION & RATES |</li>
<li>INFO |</li>
<li>ACTIVITIES |
<ul class="sub-menu">
<li>GARDEN ROUTE ACTIVITIES</li>
</ul>
</li>
<li>GOLF |</li>
<li>NEWS |</li>
<li>CONTACT US |</li>
<li>DIRECTIONS |</li>
<li>GALLERY</li>
</ul>
the CSS
/*Initialize*/
ul#menu, ul#menu ul.sub-menu {
padding:0px 0 0px 0;
margin: 0px;
/*background-color:#9A844C;*/
}
ul#menu li, ul#menu ul.sub-menu li {
list-style-type: none;
display: inline-block;
display:inline;
}
/*Link Appearance*/
ul#menu li a, ul#menu li ul.sub-menu li a {
text-decoration: none;
color: #573A2F;
padding: 0px;
display:inline-block;
font-size:10px;
}
ul#menu li a:hover {
text-decoration: none;
color: #000;
padding: 0px;
display:inline-block;
}
/*Make the parent of sub-menu relative*/
ul#menu li {
position: relative;
padding-bottom:5px;
z-index:100001;
}
/*sub menu*/
ul#menu li ul.sub-menu {
display:none;
position: absolute;
top: 20px;
left: 0;
width: 200px;
background-color:#E2D9C6;
z-index:100001;
}
ul#menu li:hover ul.sub-menu {
display:block;
z-index:100001;
}
ul#menu li ul.sub-menu:hover {
display:block;
color: #573A2F;
z-index:100001;
}
Any help would be greatly appreciated...
I have checked with your code and it is working in my system. I have checked in IE7,8 and 9.
Another suggestion just change below css and check again:
I have just changed from "ul#menu li ul.sub-menu:hover" to "ul#menu li:hover ul.sub-menu"
ul#menu li:hover ul.sub-menu {
display:block;
color: #573A2F;
z-index:100001;
}
As others have stated, your code works with IE7, IE8 and IE9.
If the issue is really with IE6, I am not going to solve your current problem, because of the following line:
It is not worth it
And with this i don't mean that YOUR WORK is not worth it, but that nobody should still develop for IE6. It's a 10 years old browser, which should be put to sleep as soon as possible. And it's not just my opinion, but Microsoft's! see HERE and notice the Microsoft copyright at page footer.
Also, see HERE for browser usage statistics: IE6 is used by just 0.6% of internet users. Is your time worth it?

Categories