Wordpress loses padding on custom sidebar - css

Here's a strange problem!
I'm using a custom sidebar which replicates the normal default sidebar except that it adds a relevant google maps widget for that page showing location of that particular event.
the map widget is not needed on any other page so that's why an almost identical custom menu has been created but with the extra map widget.
on the first image you can see the default sidebar on the right has some additional classes (.widget) and also
all the widgets are contained in divs with ids for each div
so the padding is as correct
on the second image all of the are widgets lacking don't have divs anymore so no place to add a custom classes on custom.css
required padding is missing!
if the classes were there this wouldn't be a problem!
I think i did the following:
created a custom sidebar
added widgets
created a page and replaced default rhs sidebar at time of creation
have I done it wrong?
surely the wordpress core should be adding all classes and divs with their respective id's
=====================================================================
1st edit
I used the custom sidebar and configured widgets.
all elements of the jummah custom sidebar are widgets
here's the html...
<div class="sidebar s2">
<a class="sidebar-toggle" title="Expand Sidebar">
<div class="sidebar-content">
<div class="sidebar-top group">
Jummah, Darutawheed Oxford
<p>
<p>
<p>Barak Allaahu feekum</p>
<form class="searchform themeform" action="http://darutawheed.co.uk/" method="get">
Tags
<div class="tagcloud">
<div id="calendar_wrap">
Archives
<ul>
</div>
and the css that gets generated in Jummah sidebar
.col-3cm .s2 {
float: right;
margin-right: -260px;
position: relative;
right: -100%;
}
.s2 {
width: 260px;
z-index: 1;
}
.sidebar {
padding-bottom: 20px;
position: relative;
z-index: 2;
}
==================================
this is how it should look
html
<div class="sidebar s2">
<a class="sidebar-toggle" title="Expand Sidebar">
<div class="sidebar-content">
<div class="sidebar-top group">
<div id="search-2" class="widget widget_search">
<div id="tag_cloud-3" class="widget widget_tag_cloud">
<div id="calendar-2" class="widget widget_calendar">
<div id="archives-2" class="widget widget_archive">
</div>
css
.sidebar .widget {
padding: 30px 30px 20px;
}
.widget {
color: #777777;
font-size: 15px;
overflow: hidden;
}
================================
I did a little experiment
this pic shows page using the DEFAULT sidebar
this is the JUMMAH sidebar which totally breaks the design
I tried to add a custom sidebar widget class using edit sidebar BEFORE WIDGET
<div class="custom_sidebar_widget">
and AFTER WIDGET
</div>
and the copied the padding style like this in custom.css
.custom_sidebar_widget {
padding: 30px 30px 20px;
}
but that just padded out the widgets correctly but the styling (font colour and calendar style was all messed up)
The theme is not adding the necessary divs and classes widget widget_search, widget widget_tag, widget widget_calendar etc. so this breaking the design!!
I think I've covered everything

It's very difficult to view the images without coding. Anyway! I hope the problem was your coding. As I view your site, I saw the issue between your 2nd image and default code(live site). The thing is.
You didn't use a div for your content with calss .widget
See my example.
<div class="sidebar s2">
<a class="sidebar-toggle" title="Expand Sidebar"><!-- Something here I saw in live site --></a>
<div class="sidebar-content">
<div class="sidebar-top group"><!-- Something here I saw in live site --></div>
<!-- I don't know about codes. After this one use a div with .widget class -->
<div id="myTest" class="widget">
Jummah, Darutawheed Oxford
<p>Contents Here</p>
<p>Another P Tag contents</p>
<p>Then use form</p>
<form action="http://darutawheed.co.uk/" class="searchform themeform" method="get" data-dpmaxz-eid="1">
<div id="mysform">
<input type="text" value="To search type and hit enter" onfocus="if(this.value=='To search type and hit enter')this.value='';" onblur="if(this.value=='')this.value='To search type and hit enter';" name="s" class="search" data-dpmaxz-eid="2">
</div>
</form>
</div><!--end div#myTest-->
</div>
I just use that form static way. You just have to add that class with a div. See div #myTest
Thanks
See Theme Codes 1st Edit.
/* Register sidebars
/* ------------------------------------ */
if ( ! function_exists( 'alx_sidebars' ) ) {
function alx_sidebars() {
register_sidebar(array( 'name' => 'Primary','id' => 'primary','description' => "Normal full width sidebar", 'before_widget' => '<div id="%1$s" class="widget %2$s">','after_widget' => '</div>','before_title' => '<h3>','after_title' => '</h3>'));
register_sidebar(array( 'name' => 'Secondary','id' => 'secondary','description' => "Normal full width sidebar", 'before_widget' => '<div id="%1$s" class="widget %2$s">','after_widget' => '</div>','before_title' => '<h3>','after_title' => '</h3>'));
if ( ot_get_option('footer-widgets') >= '1' ) { register_sidebar(array( 'name' => 'Footer 1','id' => 'footer-1', 'description' => "Widetized footer", 'before_widget' => '<div id="%1$s" class="widget %2$s">','after_widget' => '</div>','before_title' => '<h3>','after_title' => '</h3>')); }
if ( ot_get_option('footer-widgets') >= '2' ) { register_sidebar(array( 'name' => 'Footer 2','id' => 'footer-2', 'description' => "Widetized footer", 'before_widget' => '<div id="%1$s" class="widget %2$s">','after_widget' => '</div>','before_title' => '<h3>','after_title' => '</h3>')); }
if ( ot_get_option('footer-widgets') >= '3' ) { register_sidebar(array( 'name' => 'Footer 3','id' => 'footer-3', 'description' => "Widetized footer", 'before_widget' => '<div id="%1$s" class="widget %2$s">','after_widget' => '</div>','before_title' => '<h3>','after_title' => '</h3>')); }
if ( ot_get_option('footer-widgets') >= '4' ) { register_sidebar(array( 'name' => 'Footer 4','id' => 'footer-4', 'description' => "Widetized footer", 'before_widget' => '<div id="%1$s" class="widget %2$s">','after_widget' => '</div>','before_title' => '<h3>','after_title' => '</h3>')); }
}
}
add_action( 'widgets_init', 'alx_sidebars' );
This is the codes from the alex theme register sidebar? If am I right. Just do follow steps.
01.Just copy this code from original code. Then paste it after it.
register_sidebar(array( 'name' => 'Primary','id' => 'primary','description' => "Normal full width sidebar", 'before_widget' => '<div id="%1$s" class="widget %2$s">','after_widget' => '</div>','before_title' => '<h3>','after_title' => '</h3>'));
02.Rename the name, id and description only. Don't remove class and other stuff. If you want to add new class to your own widget. Just add myClass widget %2$s like this.
03.Then create a page as using copy of sidebar-2.php. name it sidebar-3.php.
Then call to your new sidebar for act. That's it.
If you didn't give any chance to complete that. find me I'm yeshansachithak in all networks.
Thanks

Related

Navigation Items In Page But Not Displaying WordPress

During the process of working on my new WordPress site using Humescores as the theme, I noticed that my primary navigation menu stopped displaying. Upon inspection though, one can see that the navigation and li items are indeed in the page. But I cannot get them to render. I've set the background color of the navigation to red with a yellow border so you can see where it is. And I've attempted to set the font color to white but you can see none of the links are displaying. Very wierd behavior. What gives?
From functions.php
register_nav_menus( array(
'primary' => esc_html__( 'Header', 'humescores' ),
) );
From header.php
<nav id="site-navigation" class="main-navigation" style="border: 2px solid yellow; background-color:red; color:#fff;">
<button class="menu-toggle" aria-controls="primary-menu" aria-expanded="false"><?php esc_html_e( 'Primary Menu', 'humescores' ); ?></button>
<?php
wp_nav_menu( array(
'theme_location' => 'primary',
'menu_id' => 'primary-menu',
) );
?>
</nav><!-- #site-navigation -->
ChromeDevToolsScreenShot
Try to add z-index:99999; inside the css for the navigation.

Mobile: hide menu after clicking menu link

header.php
<div class="mobile-menu">
<i class="fas fa-bars"></i>
</div>
<div class="site-nav">
<ul>
<?php
// navigation menu
wp_nav_menu(array(
'theme_location' => 'primary',
'menu_class' => 'primary-menu',
'container' => false,
'items_wrap' => '%3$s'
));
?>
</ul>
</div>
consider this as
.site-nav ul li a
JS
jQuery(document).ready(function(){
jQuery(window).load(function() { //execute after load
//responsive menu
jQuery('.mobile').on('click',function() {
jQuery('.site-nav').slideToggle('slow');
});
//fix menu when changing to mobile to desktop
var breakpoint = 767;
jQuery(window).resize(function(){
if (jQuery(document).width() >= breakpoint){
jQuery('.site-nav').show();
}else{
jQuery('.site-nav').hide();
}
});
});
});
how to hide menu page when I click other page link, every time i click the other page the menu wont hide/toggle
http://jsfiddle.net/jayllopy/vds2U/217/

How to style CodeIgniter form label

I am trying to change the color of the form labels and I was wondering how to do it.
<div class="form-group">
<div class="medium-6 columns">
<?php
echo form_label('First Name');
$data = array(
'class'=>'form-control',
'name'=>'fname',
'placeholder'=>'First Name'
);
echo form_input($data);
?>
</div>
Use always form_helper way
$attributes = array(
'class' => 'class-name-yours', // external or internal css
'style' => 'color: #000;' // or inline css, this is black color
);
echo form_label('First Name', 'firstname', $attributes); //first name is form id
In your form open if you have a id="exmaple" In your css file have you tried
#example label {
color: #222222;
}
You may need important
#example label {
color: #222222 !important;
}
And looks like your mixing foundation code with bootstrap code bootstrap col-md-6
http://getbootstrap.com/css/#grid-options
I think best option is..
<div id="firstname" style="color: orange;">
<?php
echo form_label('First Name') ;
?>
</div>

Wordpress navigation Menus

I have a problem where on my WordPress theme if i have a menu assigned in Appearance->Menus the styling is okay but if i do not have one assigned i loose the styling as my navigation bar styles on the ul tag and not the div tag. The custom menu's use the ul tag with the class specified but if no menu is assigned to the location it puts the styling in the div tag.
As you can see on the picture below this is what i get outputted when menu specified
Menu Specified
this outputs
<div id="menu_dropdown">
<ul id="menu-default" class="dropdown dropdown-horizontal" style="left: 14px; top: 38px; margin-right: 0; margin-top: 0">
using the following code in functions.php
function register_my_menus() {
register_nav_menus(
array( 'primary' => __( 'Header Menu' ) )
);
}
and the following in header.php
<div id="menu_dropdown">
<?php wp_nav_menu( array( 'theme_location' => 'primary',
'menu' => '',
'container' => '',
'container_class' => '',
'container_id' => '',
'menu_class' => 'dropdown dropdown-horizontal',
'menu_id' => '',
'items_wrap' => '<ul id="%1$s" class="%2$s" style="left: 14px; top: 38px; margin-right: 0; margin-top: 0">%3$s</ul>', ) ); ?>
</div>
but the styling goes like this when no menu specified
Menu Not Specified
and outputs
<div id="menu_dropdown">
<div class="dropdown dropdown-horizontal"><ul>
</ul>
</div></div>.
This is not a styling issue as in my stylesheet i have all the correct classes e.g ul.dropdown etc.
Try instead this:
keep blank your items_wrap
and try with this one:
<div id="menu_dropdown"> <?php wp_nav_menu( array( 'theme_location' => 'primary', 'menu' => '', 'menu_class' => 'dropdown dropdown-horizontal', 'menu_id' => 'menu-default' ) ); ?> </div>
And now play with your CSS.
Thanks.

Issue with floating divs - how can I have the widgets alongside the posts, not below?

I am struggling to figure out how to align widgets to the right of the main column on this page: http://carolineelisa.com/wordpress/
It seems that the top 3 widgets are forcing the content area to the full width, so that the right hand side widgets drop below the left column.
Any tips for achieving this with CSS? I'd rather not have to mess with the templates of functions.php file to move the top widgets into their own div.
Thanks!
You have to place the two right side divs before the post divs.
<div id="content" class="hfeed content">
<div id="primary" class="sidebar aside">
This instead
<div id="primary" class="sidebar aside">
<div id="content" class="hfeed content">
Try placing your inside
<div id="content" class="hfeed content">
<div id="utility-before-content" class="sidebar utility">
<div id="primary"></div>
<div id="post-49" class="hentry post publish post-1 odd author-admin sticky category-news">
...
It seems CSS will not suffice in this case...
Thanks #Frost and #Justin Lucas for your suggestions. For my exact needs it seems that I need to move the top 3 widgets out of the #content div and place them above.
So now the HTML looks like this:
<div id="feature" class="widget widget_text widget-widget_text">
<div id="feature" class="widget widget_text widget-widget_text">
<div id="feature" class="widget widget_text widget-widget_text">
<div id="content" class="hfeed content">
<div id="primary" class="sidebar aside">
For anyone who may be interested, I did this by creating a new sidebar element in my child theme (of Hybrid) by adding the following to the functions.php file:
register_sidebar( array(
'name' => 'Features',
'id' => 'id-of-widget-area',
'before_widget' => '<div id="feature" class="widget %2$s widget-%2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>'
) );
add_action( 'hybrid_before_container', 'my_widget_area', 20 );
function my_widget_area() {
dynamic_sidebar( 'id-of-widget-area' );
}
I got this from: http://themehybrid.com/support/topic/new-widget-area#post-17991

Resources