WordPress Sidebar widgets not staying - php

WordPress 3.5
I build a dynamic sidebar via WordPress register_sidebar documentation to which looks like:
$sidebar = array(
'name' => 'Main Side Bar',
'id' => 'Aisis_Side_Bar',
'before_widget' => '<li>',
'after_widget' => '</li>',
'before_title' => '<h2>',
'after_title' => '</h2>'
);
register_sidebar($sidebar);
The problem is, when I go into the widgets section of the admin section to drag and drop widgets onto the sidebar, everything works. If I refresh or leave that page and come back the widgets are gone and the sidebar is empty.
They also do not show up on the front end.
Ideas?

Posting here because it is too long for a comment, not really an answer.
And then you have something like <?php dynamic_sidebar('Main Side Bar'); ?> in your template?
There are two times I've seen WordPress widgets disappear, and both are related to the page doing everything via Ajax. The first is when you are only viewing the Appearance >> Widgets and you leave the page open for a long time, WordPress signs you out but the page keeps acting like normal, even though nothing is saving.
The other time is when there are multiple admins. All widgets and their options get saved every time you click save on any widget, it doesn't just save the info for the widget you clicked save on. So if another person is logged in as admin and is viewing Appearance >> Widgets, then you save your widget to "Main Side Bar", it won't show up in their screen unless they refresh Appearance >> Widgets. So now if they click save on any widget, it saves "Main Side Bar" as empty and "erases" your widget.
Also, if you create multiple widget areas, be sure to add them below the other ones in functions.php. WordPress puts widgets in the proper area based on its ID number, not based on its name or the ID you set. So if "ABC" is the first widget area you register, then you drop some widgets in, then you go register a new area "DEF" above the other one in functions.php, ABC will now be empty.
If none of those situations apply to you, you might want to try changing the ID to use hyphens just for the heck of it. Then start looking in your error log, disabling all plugins, making sure mod_security isn't intercepting the post, stuff like that.

Old question, but today after 3 years, im still have trouble with it, my fix:
Change id of sidebar array from cameCase to something like snake_case or spinal-case !

Related

Left Sidebar on Wordpress won't create menu

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.

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!

How to Disable Wordpress Default Widget in one SideBar

I have developed a Premium theme, but as soon as theme is installed wordpress by default throw some of its widgets in Header Area.
The theme looks very ugly at it first appearance when it is virgin w/o all the theme settings.
Although those widgets can be deleted mannualy from the Widget area of Header, but initially the buyer of that theme wouldn't get a Good Notion.
I want to disable wordpress few default widgets in one particular side bar.
I tried various things and researched on various forums.
I got few solutions such as : WordPress widgets can be completely disabled, but that what I do not want.
Has any one faced the same challenge like me. Please advice.
Summary of The Question: I want to disable wordpress default widgets in only one particular sidebar/widget area.
Thanks!
register a custom area for your header
function theme_widgets_init() {
register_sidebar(array(
'name' => __('Header widget', 'theme'),
'id' => 'sidebar-1',
.............
.............
));
add_action('widgets_init', 'theme_widgets_init');
and output it in your header like that:
<?php dynamic_sidebar('sidebar-1'); ?>

Having Problems Getting The Correct Widget Area To Display

I have probably missed something but I have been trying to work out what and I am having no luck.
I have added a new page template to my wordpress site, created a new widget area (necessary as this is how the original designer built the site).
However, the page appears to be calling content from another widget area.
The page in question is http://www.haylockpittman.co.uk/builders-painters-decorators-and-refurbishment-contractors-surrey/ and it appears to be calling widget area "New Paint" despite the code calling for "paint surrey" which contains the correct text for the widget area.
For note the widget area is basically the bottom half of the page.
I hope someone might be able to help me get my head round this.
Thanks
As you have created a separate sidebar, now you must be seeing that in your admin panel.
So just add the widgets you want to appear in the sidebar.
Next go to your sidebar.php page, there you cana put a condition i.e. for the products page
If your products page is a separate template then use the name of the file i.e.
if ( is_page_template('your-template.php') ) {
register_sidebr('name of the sidebar');
} else {
register_sidebr('name of the sidebar');
}

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