Left Sidebar on Wordpress won't create menu - php

I tried googling this, but not having much luck...
I have been able to create a menu using wordpress and entering this code in my header:
<?php wp_nav_menu( array( 'theme_location' => 'header-menu' ) ); ?>
And this in my scripts part:
function register_custom_menu() {
register_nav_menu('header-menu',__( 'Header Menu' ));
}
add_action( 'init', 'register_custom_menu' );
But it seems that when trying to sort it, using the left side bar in the customize theme mode, it will not sort the menu nor will it remove any part of the menu that I add or remove using it.
From what I can tell it's just pulling my pages that I created within wordpress.
Keep in mind, this is a new theme I'm creating - my first theme. I have no PHP experience. Trying to learn as I go.
Picture of issue
I removed some of the names of the links for public view. I need to figure out how to also style this properly, but I've seen some other posts about it, so I'll review those later.
If someone can help me get this side menu to work with my current menu that would be great!

If you try altering your wp_nav_menu call to the following (no parameters):
<?php wp_nav_menu(); ?>
It should fall back on the first non-empty menu. While you may want additional menus later/will likely want to customize your menu(s) more, this should help with troubleshooting as whatever initial menu you have created (is non-empty) is the menu being edited by the customize page.
From what I can tell it's just pulling my pages that I created within
wordpress.
This likely relates to the setting "Automatically add new top-level pages to this menu" in the menu settings tab. This may be found under Appearance >> Menus, or under Customize >> Menus >> Clicking on the arrow to the right of your primary menu >> menu options (at the bottom of the resulting tab on the left).

Have you tried building the menu through Appearance-->Menu?

In the Wordpress backend, go to "Design > Menus", create a new menu there, add all entries you want to have, give it a name and in the "positions" tab on that page, assign it to the defined position in your theme (header-menu in your case). And disable the option to add all new pages/posts automatically.

Related

Creating a second header navigation menu in Wordpress

I would like to create a second navigation menu that goes below the main one (The one that contains the "About" and "Contact" etc. categories). This one would have images that have links and also which show text under them when hovered on. I have already created the necessary HTML and CSS for it, I just don't know how I would implement that into my site. The images and links are in a table, but the Wordpress navigation menu is a list, so I'm kind of stuck on what to do.
Are you using a default/premium/free theme, or did you create one by yourself?
I assume the first, so here are a few things you need to know.
Wordpress uses hooks, so you can "link" your code at a certain point of their code, when a website is called. In its codex, you can learn more about how navigation menus are registered and called later on.
A theme is something like a base, when you create your own website. You can create child themes and implement every further functionality and design changes
right there.
In short: implement your menu, put it in your child theme and use the hooks to get it where you need.
Standard way of adding a secondary menu to a theme is as follows.
register_nav_menus( array(
'primary' => __( 'Primary Menu', 'yourtheme'),
'secondary' => __( 'Secondary Menu', 'yourtheme' ),
) );
Nevermind, the question I was trying to ask is where do I put my HTML code of the table so that it shows up on the header, but I found the solution through sheer luck. I put the HTML into the header.php of my child theme and linked the CSS classes to those that I pasted into the style.css . Still, thanks to those who tried to answer!

Primary nav menu would not relocate to the header

I'm using the Genesis framework in wordpress, I have a header set with a logo and a menu that currently is displayed under the header, I want it in the header.
I know about the option to use a custom men and drag it to the menu right widget, but that simply does not work, everything is unticked in the menu settings but it just wouldn't snap there, it just stays under the header.
Please check the below link it will help you
https://my.studiopress.com/snippets/navigation-menus/
OR Use This
remove_action( 'genesis_after_header', 'genesis_do_nav' );
add_action( 'genesis_before_header', 'genesis_do_nav' );
What actually solved the problem is something I tried before but didn't work.
The first stage is to use the custom menu on the Widgets and drag it to the Menu Right widget, save it and add the menu to it.
In the menu settings, everything has to be ticked off (all the 3 check boxes).
Then I had to insert the logo into the menu right widget and float it to the left to make sure it's aligned properly with the menu.
I hope it helps anyone.

Order Pages in Wordpress

I am new to CMS development, I prefer the MVC concept for every job. But just know the client requested to develop a website built in WordPress. Everything is OK but I can't find to order pages in WordPress.
The case is: first I create a home page and then I create other pages, but the problem is every time I add new pages, it will be placed in my first menu.
So I want to move the home pages in first menu.
Please help, thanks.
You can create a custom menu (with the pages/links you want, and the order you want !). Then you can add that menu to be the new navigation menu (both header, and footer if you want)
References:
WordPress Menu (here you can find the step by step 'guide')
Just go to Appearance --> Menus and then you'll be able to create menus and edit at will. And if you need to create specific menus, see WP nav menu page. There you'll see several code samples, but you'll need something as simple as
<?php wp_nav_menu( array('menu' => 'Main Nav' )); ?>

Programming custom PHP with Wordpress

I have a question regarding PHP and Wordpress.
I recently started using Wordpress for a simple website but there is still one thing that I just don't understand. Lets say I made a cool website in php that also cointains my header, my footer and my menu. How do I implement the Wordpress CMS so that someone else can add an item in the menubar that I made, instead of adding an item in a theme made by someone else? I have a hard time finding such tutorials because most of them are for people with no programming interests and because of that they don't explain such things.
If your only concern is how to connect your menu to the wordpress admin, you can check this link: wp_nav_menu()
that wordpress function will then generate a list of the menu items you add on the admin.
For example use this on your theme to display a menu from the admin with the name "Main Menu":
<div class="my-menu">
<?php wp_nav_menu(array('menu' => 'Main Menu' )); ?>
</div>

wordpress widgets will not save

I followed this tutorial here to get a "base" theme set up:
http://themeshaper.com/2009/06/22/wordpress-themes-templates-tutorial/
Everything has been working great, but now on the last part, styling the "news feed" page I want the sidebar to show up. Everything in the theme, for what I can understand is set up correctly. There are two widget areas defined in the functions.php "primary" and "secondary", the unmodified functions.php and sidebar.php can be viewed here:
http://code.google.com/p/your-wordpress-theme/source/browse/trunk/functions.php
and
http://code.google.com/p/your-wordpress-theme/source/browse/trunk/sidebar.php
So this is what happens, I go into the appearance -> widgets manager in the admin. The primary and secondary widget area show up on the right.
I drag the categories and recent posts widgets to the primary (or secondary it doesnt matter). I click save on each widget for good measure and then if I browse away and come back the widgets are gone. Nothing is saved.
I'm not using any plugins, I have no 3rd party or custom widgets. These are just the default vanilla wordpress widgets.
I have debugging enabled in the config file but I get no output of any error when I save the widget config. I've even checked the page source after updating the widget and there is no hidden errors at the bottom as some have suggested.
If someone cannot tell me how to fix this, is there anyone that can at least tell me how to debug this, or get some sort of error message from this thing?
Try this
Go to your wp-admin --> and appearance --> widgets
then on the right top you will see a screen options button (a popdown menu) from there Enable accessibility mode and try your widgets
Some suggestions:
-install debug bar http://wordpress.org/extend/plugins/debug-bar/
enable WP_DEBUG in wp-config
try to clear cache / use different browser or computer
I was having this issue and thought I would add my findings and update this post. I am currently running version 4.9.8. I learned that you can not use Camel case as the id.
This line does not work.
register_nav_menu( 'newThemeArea', __( 'New Widget Area', 'theme' )
This line does work
register_nav_menu( 'newthemearea' , __( 'New Widget Area', 'theme' )
In my case, my widget had input fields with type="number", and the min attributes had fractions of numbers -- once I've rounded them up and showed them as ints, it worked.
Set id of widget like
'id' => 'high-light-header',
instead of
'id' => 'highLightHeader',

Categories