So I have been using a HTML template for a website, and added Wordpress functionality. However, my navigation within Header.php just uses get_permalink for page links. I want to keep the same navigation menu with all it's functionality, but allow pages to be added within the dashboard.
The current code is as follows:
<!-- Overlay Navigation Menu -->
<div class="overlay-navigation-wrapper enter-bottom" data-no-scrollbar data-animation="slide-in">
<div class="overlay-navigation-scroll-pane">
<div class="overlay-navigation-inner">
<div class="v-align-middle">
<div class="overlay-navigation-header row collapse full-width">
<div class="column width-12">
<div class="navigation-hide overlay-nav-hide">
<span class="icon-cancel"></span>
</div>
</div>
</div>
<div class="row collapse full-width">
<div class="column width-12">
<nav class="overlay-navigation nav-block">
<h4 class="menu-title">Website Title</h4>
<ul>
<li> Home </li>
<li> About </li>
<li> Treatments & Offers </li>
<li> Store </li>
<li> Contact </li>
</ul>
</nav>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Overlay Navigation Menu End -->
<div class="wrapper reveal-side-navigation">
<div class="wrapper-inner">
<!-- Header -->
<header class="header header-bottom header-fixed-on-mobile header-transparent" data-sticky-threshold="window-height" data-bkg-threshold="100">
<div class="header-inner">
<div class="row nav-bar">
<div class="column width-12 nav-bar-inner">
<div class="logo">
<div class="logo-inner"> <img src="" alt="Sartre Logo" /> <img src="" alt="Sartre Logo" /> </div>
</div>
<nav class="navigation nav-block secondary-navigation nav-right">
<ul>
<li>
<!-- Button -->
<div class="v-align-middle"> Book Now </span> </div>
</li>
<li class="aux-navigation hide">
<!-- Aux Navigation -->
<span class="icon-menu"></span>
</li>
</ul>
</nav>
<nav class="navigation nav-block primary-navigation nav-center">
<ul>
<li> Home </li>
<li> About </li>
<li> Treatments & Offers </li>
<li> Store </li>
<li> Contact </li>
</ul>
</nav>
</div>
</div>
</div>
</header>
<!-- Header End -->
<!-- MAIN CONTENT GOES HERE-->
</div>
</div>
The code is quite bloated, but allows for the mobile responsiveness and other Javascript effects that come with the theme.
What's the best way to approach this? Thanks
Step 1: Register a navigation menu in your functions.php
<?php
function my_wp_nav_menu(){
register_nav_menus( array(
'primary' => 'Main Navigation'
) );
}
add_action( 'after_setup_theme', 'my_wp_nav_menu' );
Step 2: Go into Appearance->Menus in your Dashboard, add your navigation items, and select Main Navigation as the menu.
Step 3: Replace the navigation's uls in your HTML with:
<?php
wp_nav_menu( array(
'container' => '',
'theme_location' => 'primary'
) );
This will replace your list with a WordPress menu that you can control in WordPress. By default, wp_nav_menu wraps the menu list with a div which is why we set 'container' => '' so all you get is the menu list markup.
Related
I am designing a website/software using PHP. I have written the code for a few pages, however when I include the footer.php file, the HTML text alignment seems to be changing and I'm not sure why. I am also attaching the images for better understanding. This is happening for all the pages on which I'm including the footer, I have mentioned the code below for footer from the image.
Before Adding the Footer the text is center aligned
After including footer.php the text automatically becomes left aligned
footer.php
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="assets/css/bootstrap.min.css">
<link rel="shortcut icon" href="assets/images/leaf.png">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<style>
i {
width: 15px;
height: 15px;
}
</style>
</head>
<body>
<!-- Footer -->
<footer class="bg-dark text-center text-white mb-4">
<!-- Grid container -->
<div class="container p-4">
<!-- Section: Social media -->
<section class="mb-4">
<!-- Facebook -->
<a title="Facebook" class="btn btn-outline-light btn-floating m-1" href="https://www.facebook.com/SaiNirmanBiocoal" role="button"
><i class="fa fa-facebook"></i
></a>
</section>
<!-- Section: Social media -->
<!-- Section: Form -->
<section class="mb-4">
<img src="assets/images/SNB-latest.png" style="height:50px;width: auto;" alt="Sai Nirman Biocoal Logo">
</section>
<!-- Section: Form -->
<!-- Section: Text -->
<section class="mb-4">
<p>
Sai Nirman Biocoal<br>
"Fueling the Future with Sustainable Energy"
</p>
</section><br>
<!-- Section: Text -->
<!-- Section: Links -->
<section class="">
<!--Grid row-->
<div class="row ">
<!--Grid column-->
<div class="col-lg-3 col-md-6 mb-4 mb-md-0">
<h5 class="text-uppercase">Customer Care</h5>
<ul class="list-unstyled mb-0">
<li>
Contact Us
</li>
<li>
FAQs
</li>
<li>
Privacy Policy
</li>
<li>
Terms of Service
</li>
</ul>
</div>
<!--Grid column-->
<!--Grid column-->
<div class="col-lg-3 col-md-6 mb-4 mb-md-0">
<h5 class="text-uppercase">SNB Website</h5>
<ul class="list-unstyled mb-0">
<li>
About Us
</li>
<li>
Products
</li>
<li>
Careers
</li>
<li>
Contact
</li>
</ul>
</div>
<!--Grid column-->
<!--Grid column-->
<div class="col-lg-3 col-md-6 mb-4 mb-md-0">
<h5 class="text-uppercase">My Account</h5>
<ul class="list-unstyled mb-0">
<li>
Sign Out
</li>
<li>
Reset Password
</li>
<li>
Dashboard
</li>
<li>
Ledger
</li>
</ul>
</div>
<!--Grid column-->
</div>
<!--Grid row-->
</section>
<!-- Section: Links -->
</div>
<!-- Grid container -->
<div class="text-center p-3" style="background-color: rgba(0, 0, 0, 0.2);">
<a class="text-white" href="https://www.sainirmanbiocoal.com/">sainirmanbiocoal.com</a>
</div>
</footer>
<!-- Footer -->
<script src="assets/vendors/jquery/jquery-3.4.1.js"></script>
<script src="assets/vendors/bootstrap/bootstrap.bundle.js"></script>
</body>
</html>
I tried to add style tag in footer.php and define the html and body properties as center align since the problem seems to be due to the footer code for some reason but it does not work. I even tried including header.php again at the end instead of footer.php and the same problem occurs, so I'm not really sure as to what exactly might be the issue.
i try apply theme gentelella with my project using framework yii 1.1. Here i use extension Yii 1.1 that is CMenu, when I want to match the original code template i have a problem with my project in side-bar ( my menu ), which should (template menu)
for my code:
code
!-- sidebar menu -->
<div id="sidebar-menu", class="main_menu_side hidden-print main_menu">
<div class="menu_section">
<?php
if(!Yii::app()->user->isGuest)
{
$this->widget('zii.widgets.CMenu',array(
'htmlOptions'=>array('class'=>'nav side-menu'),
'submenuHtmlOptions'=>array('class'=>'nav child_menu'),
'encodeLabel'=>false,
'items'=>Yii::app()->user->getState('menu'),
));
}
else
echo '<div id=\'footer\'></div>';
?>
</div>
</div>
<!-- /sidebar menu -->
for the template code: code template
<!-- sidebar menu -->
<div id="sidebar-menu" class="main_menu_side hidden-print main_menu">
<div class="menu_section">
<h3>General</h3>
<ul class="nav side-menu">
<li><a><i class="fa fa-home"></i> Home <span class="fa fa-chevron-down"></span></a>
<ul class="nav child_menu">
<li>Dashboard</li>
<li>Dashboard2</li>
<li>Dashboard3</li>
</ul>
</li>
</ul>
</div>
<!-- <div class="menu_section"> -->
<ul class="nav side-menu">
<li><a><i class="fa fa-bug"></i> Additional Pages <span class="fa fa-chevron-down"></span></a>
<ul class="nav child_menu">
<li>E-commerce</li>
<li>Projects</li>
<li>Project Detail</li>
<li>Contacts</li>
<li>Profile</li>
</ul>
</li>
</div>
</div>
<!-- /sidebar menu -->
i have try to insert <ul class="nav child_menu"> under <div class="menu_section"> but what happens is that the menu does not appear :(
please help,
thanks
I have problems to convert HTML menu to WP menu. I have div elements inside menu and that div elements are vertical line between li elements. I try do that with Walker class, but i couldn't find solution.
This is code:
<div class="nav-holder">
<i class="fa fa-times-circle"></i>
<nav class="hamburger-menu">
<ul>
<div class="ver-line"></div>
<li class="scroll-link">
biografija
</li>
<div class="ver-line"></div>
<li class="scroll-link">
portfolio
</li>
<div class="ver-line"></div>
<li class="scroll-link">
kontakt
</li>
<div class="ver-line"></div>
</ul>
</nav>
</div>
<!-- nav-holder -->
I'm working on http://pizzli.com/ephraimwp/inner-page-1/. I'm trying to get the content of #innernav (which contains the ul) to float to the left edge of the column it is in, so that it is even with #bannerbar. Please see my code below.
<div id="bannerbar"><?php the_title();?></div>
<div class="row" style="padding-top:35px;">
<div class="col-md-4">
<div id="innernav">
<ul>
<li>Our Purpose</li>
<li>Why Choose PSP</li>
<li>Our Process</li>
<li>Our History</li>
<li>Blog</li>
<li>Glossary</li>
<li>Contact</li>
</ul>
</div>
</div>
<div class="col-md-8">
<h2 style="font-size:20px;color:#2c4276;"><?php the_title();?></h2>
<div style="color:#a2a2a2;font-size:18px;">
<?php
if ( have_posts() ) {
while ( have_posts() ) {
the_post();
the_content();
} // end while
} // end if
?>
</div>
</div>
</div>
You need to remove some padding from elements surrounding the menu.
I recommend wrapping this section with a class of left-container (or something similar), and also adding a class to the innernav. Classes are better than IDs for styling.
<div class="left-container">
<div class="col-md-4">
<div id="innernav" class="innernav">
<ul>
<li>Our Purpose</li>
<li>Why Choose PSP</li>
<li>Our Process</li>
<li>Our History</li>
<li>Blog</li>
<li>Glossary</li>
<li>Contact</li>
</ul>
</div>
</div>
</div>
Then, you can remove the padding with CSS, and your menu will be aligned.
.left-container > .col-md-4,
.left-container .innernav ul {
padding-left:0;
}
You can achieve in many ways first in your custom css .no-gutter{padding:0!important; margin:0!important;} add these lines
then in your html <div class="col-md-4 no-gutter">.
Now you can use no-gutter where ever you dont need padding from bootstrap.
for ul #innernav ul{padding-left:0px;}
you have padding that you have to get rid of on the col-md-4 and the <ul> :
<div class="col-md-4" style="padding-left: 0px;"> // here padding taken out
<div id="innernav">
<ul style="padding-left: 0px;"> // here padding taken out
<li>Our Purpose</li>
<li>Why Choose PSP</li>
<li>Our Process</li>
<li>Our History</li>
<li>Blog</li>
<li>Glossary</li>
<li>Contact</li>
</ul>
</div>
</div>
i'm new in wordpress and i'd like to replace the footer with a pure html code.
i mean, i till want the "container" generated by wp, but inside i want to use pure html code.
i tried changing the content of "partials/footer-layout.php" to this code, and i'm able to see the code, but not to click the links...
any ideas?
<?php
/**
* #package Make
*/
// Footer Options
$footer_layout = (int) get_theme_mod( 'footer-layout', ttfmake_get_default( 'footer-layout' ) );
?>
<footer id="site-footer" class="site-footer footer-layout-<?php echo esc_attr( $footer_layout ); ?>" role="contentinfo">
<div class="footer-text">
<!-- CUSTOM FOOTER CODE STARTS HERE -->
<div class="footer-custom-container">
<div class="footer-column-one">
<h6>Title</h6>
<ul>
About us
<li>Contact us</li>
<li> </li>
<li>Careers</li>
</ul>
</div>
<div class="footer-column-two">
<h6>first column</h6>
<ul>
<li>Support</li>
<li>FAQ</li>
<li>User guides</li>
<li>Download app</li>
</ul></div>
<div class="footer-column-three">
<h6>Social & media</h6>
<ul>
<li>Facebook</li>
<li>Twitter</li>
<li> </li>
<li>Press</li>
</ul></div>
<div class="footer-column-four">
<h6> </h6>
<ul>
<li> </li>
</ul></div>
<div class="footer-column-five">
<h6>Title</h6>
<ul>
<li>For business</li>
<li>For installers</li>
<li>Terms & conditions</li>
<li>Privacy policy</li>
</ul></div>
<div class="footer-column-six">
<h6>first column</h6>
<ul>
<li>Store</li>
<li>Login</li>
</ul></div>
</div>
<!-- CUSTOM FOOTER CODE ENDS HERE -->
</div>
</footer>
Your HTML code isn't XHTML-compliant. There's a missing <li>...</li>.
Some possible solutions:
1- try to add links to the anchor tags and check if it works.
2- check if there's a HTML element which overlaps the anchor tags. Use firebug or any other developer tool to check if there's an overlapping element.
3- check if there's a Javascript event which is called once you click on the anchor. Use a Javascript debugger (Firebug etc.).
Here's the updated code:
<?php
/**
* #package Make
*/
// Footer Options
$footer_layout = (int) get_theme_mod( 'footer-layout', ttfmake_get_default( 'footer-layout' ) );
?>
<footer id="site-footer" class="site-footer footer-layout-<?php echo esc_attr( $footer_layout ); ?>" role="contentinfo">
<div class="footer-text">
<!-- CUSTOM FOOTER CODE STARTS HERE -->
<div class="footer-custom-container">
<div class="footer-column-one">
<h6>Title</h6>
<ul>
<li>About us</li>
<li>Contact us</li>
<li> </li>
<li>Careers</li>
</ul>
</div>
<div class="footer-column-two">
<h6>first column</h6>
<ul>
<li>Support</li>
<li>FAQ</li>
<li>User guides</li>
<li>Download app</li>
</ul>
</div>
<div class="footer-column-three">
<h6>Social & media</h6>
<ul>
<li>Facebook</li>
<li>Twitter</li>
<li> </li>
<li>Press</li>
</ul>
</div>
<div class="footer-column-four">
<h6> </h6>
<ul>
<li> </li>
</ul>
</div>
<div class="footer-column-five">
<h6>Title</h6>
<ul>
<li>For business</li>
<li>For installers</li>
<li>Terms & conditions</li>
<li>Privacy policy</li>
</ul>
</div>
<div class="footer-column-six">
<h6>first column</h6>
<ul>
<li>Store</li>
<li>Login</li>
</ul>
</div>
</div>
<!-- CUSTOM FOOTER CODE ENDS HERE -->
</div>
</footer>
Often when you can't click a link, it is a case that a layer is positioned on top of it.
Use a code inspector such as Firebug, and see if there are any 'invisible layers' above that area.
There is also the chance that css has cursor:none applied so it doesn't look like you can click it, but it can. Try replacing your # links with real links.
Also, About us needs li tags around it, but I doubt that is the issue.