fancymenu | Fancy AtmosphereJS style menu | Menu library
kandi X-RAY | fancymenu Summary
kandi X-RAY | fancymenu Summary
Fancy AtmosphereJS style menu.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of fancymenu
fancymenu Key Features
fancymenu Examples and Code Snippets
Community Discussions
Trending Discussions on fancymenu
QUESTION
I'm using a custom HTML CSS menu which I like on a WordPress theme. Since I don't know how to make it work from the backend (at all), I'm trying to hide menu items when visiting its page with the help of the page title.
I found out that $single_post_title
is the page title in WordPress. So I tried to hide menu items using following code. I used this for other menu items as well.
ANSWER
Answered 2018-May-09 at 03:53If you don't mind, I'm going to pick apart your code a bit (don't worry, it's to help you!)
There's a couple issue's you're dealing with (and going to be dealing with). First of all, I'd seriously consider sticking within the WordPress ecosystem if you're going to use it, unless you're going Headless with it.
Barring that, let's continue. In general, you shouldn't rely on variables that you haven't defined in your current scope yourself. Who knows where $single_post_title
was defined, or if it even was.
WordPress has some relatively 'nicely' named PHP functions to interact with Posts and Pages (many of which will show up as the first result in Google for a search like "Get the current page title in WordPress")
The standard way of getting a page/post title is with the get_the_title()
function.
Another issue is that it's quite a mess to load in some CSS to hide an element if you have access to the element's source code, just skip the element conditionally!
Lastly, generally speaking ID's don't need (or rather just shouldn't have) a pound sign in front of them. Languages that target them will put that in there for you. Something else to consider is your hard coded href
attributes have upper case letters, like it's a combination of a slug
and title
. I'd clarify what's what.
All what I said in mind, I'd drop the first block of code you have, and replace the menu code with the following:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install fancymenu
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page