• I have set up multiple dynamic sidebars in my child theme. Sidebar.php looks like:

    <div id="sidebar">
    <?php
    $metadata = get_post_meta (get_post()->ID);
    $template = $metadata['_wp_page_template']['0'];
    ?>
    <?php if (get_post_type() == 'portfolios' || (get_post()->post_title == 'Portfolio' && get_post_type() == 'page')) { /* portfolios */ ?>
    	<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Portfolip') ) : ?>
    	<?php endif; ?>
    <?php } ?>
    <?php if (get_post_type() == 'download' || (get_post()->post_title == 'Downloads' && get_post_type() == 'page')) { /* download */ ?>
    	<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Downloads') ) : ?>
    	<?php endif; ?>
    <?php } ?>
    <?php if (get_post_type() == 'page' && $template == 'book.php') { /* page */ ?>
    	<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Book') ) : ?>
    	<?php endif; ?>
    <?php } ?>
    <?php if (get_post_type() == 'post' || (get_post_type() == 'page' && $template == 'page-blog.php')) { /* blog */ ?>
    	<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Blog') ) : ?>
    	<?php endif; ?>
    <?php } ?>
    	<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Sidebar') ) : ?>
    	<?php endif; ?>
    </div> <!-- end sidebar -->

    As I am controlling what sidebars display on what pages without using templates which I can’t control in some cases (using Pods for custom content types). The generated html in one case is:

    <div id="sidebar">
    	<div id="nav_menu-9" class="widget widget_nav_menu">
    		<h3 class="title">Downloads</h3>
    		<div class="widget_content">
    			<div class="menu-downloads-container">
    				<ul id="menu-downloads" class="menu">
    					<li id="menu-item-783" class="menu-item menu-item-type-post_type menu-item-object-download menu-item-783"><a href="https://127.0.0.1/download/godaddy-reseller-plugin/">GoDaddy Reseller Plugin</a></li>
    					<li id="menu-item-784" class="menu-item menu-item-type-post_type menu-item-object-download menu-item-784"><a href="https://127.0.0.1/download/site-change-detection/">Site Change Detection</a></li>
    					<li id="menu-item-785" class="menu-item menu-item-type-post_type menu-item-object-download menu-item-785"><a href="https://127.0.0.1/download/php-compare-directories/">PHP Compare Directories</a></li>
    					<li id="menu-item-786" class="menu-item menu-item-type-post_type menu-item-object-download menu-item-786"><a href="https://127.0.0.1/download/larrys-form-generation/">Larry’s Form Generation</a></li>
    					<li id="menu-item-787" class="menu-item menu-item-type-post_type menu-item-object-download menu-item-787"><a href="https://127.0.0.1/download/db-schema-management/">DB Schema Management</a></li>
    					<li id="menu-item-788" class="menu-item menu-item-type-post_type menu-item-object-download menu-item-788"><a href="https://127.0.0.1/download/validation-javascript/">Validation Javascript</a></li>
    				</ul>
    			</div>
    		</div> <!-- end .widget_content -->
    	</div> <!-- end .widget -->
    	<div id="nav_menu-10" class="clearfix widget widget_nav_menu">
    		<h3 class="title">Hosting</h3>
    		<div class="wrapper clearfix">
    			<div class="widget_content">
    				<div class="menu-hosting-container">
    					<ul id="menu-hosting" class="menu">
    						<li id="menu-item-856" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-has-children menu-item-856"><a href="https://127.0.0.1/hosting/">Website Hosting</a>
    							<ul class="sub-menu">
    								<li id="menu-item-864" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-864"><a href="https://127.0.0.1/hosting-plans/">Hosting Plans</a></li>
    							</ul>
    						</li>
    					</ul>
    				</div>
    			</div> <!-- end .widget_content -->
    		</div> <!-- end .wrapper -->
    	</div> <!-- end .widget -->
    </div> <!-- end sidebar -->

    Both widgets are Custom Menu widgets but notice that the first one doesn’t have the <div class=”wrapper clearfix”> div. This is causing me issues as that div has the following css applied and this is causing a blank space near the bottom of the widget:

    #sidebar .widget .widget_content {
        background: rgba(0, 0, 0, 0) url("images/sidebar_widget_separator.png") no-repeat scroll 0 0;
        padding: 10px;
    }

  • The topic ‘Issue with the built in Custom Menu Widget’ is closed to new replies.