• Resolved Major_1012

    (@major_1012)


    I am trying to put up a new page on a customer’s site. He paid someone to write this site and as far as I can see it is not a published theme. Since that time someone else has worked on it but with dismal results.

    I have two sidebars, left and right. Here is the code from the Left one;

    <?php
    /*
    Template Name: sidebar.php
    */
    ?>
    	   <nav id="sidebarL">
                    <?php     wp_nav_menu('side');
                                ?>
                        </nav>

    This does generate a left sidebar which shows a basic WP menu, but does not allow any of the page content to show – here is a screenshot of the resulting page;
    https://gyazo.com/2e9c4c6c4b75c9d5f847ffb87af95039

    Then there is the right sidebar, it only generates an error, but it also contains html <div> tags, which got me scratching immediately;
    https://gyazo.com/aa26a92c72e6c12d21882ce4cc303cff

    Here is the code;

    <?php
    /*
    Template Name: sidebarL.php
    */
    ?>
    if ( is_active_sidebar( 'sidebar-2' ) ) : ?>
    	<div id="primary" class="sidebar-container" role="complementary">
    		<div class="sidebar-inner">
    			<div class="widget-area">
    				<?php dynamic_sidebar( 'sidebar-2' ); ?>
    			</div><!-- .widget-area -->
    		</div><!-- .sidebar-inner -->
    	</div><!-- #tertiary -->
    <?php endif; ?>

    Obviously there are no sidebars running on the site now, so whatever this person was trying to do, did not work out.

    I am in the process of learning coding but writing a sidebar.php from scratch is presently over my head. I did look through the style.css to see if these ids or classes were being called there. They are not.

    Is this salvageable at all? The presence of the <div> tags, a closing ?> without a corresponding opening <?php, and what seems to be a misplaced ) has me worried.

    I tried fixing this by changing what I saw that was wrong, but when I got rid of all the errors I still had a big blank white page.

    Don’t care about the left sidebar at all, or even about having two, but do need the right one.

    Any ideas/suggestions/hope would be appreciated. Just don’t want to give up, but I am for tonight!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Howdy Major_1012,

    This is a bit tough to diagnose without more code, but I can tell you the code sample you posted has a clear error:

    This:

    <?php
    /*
    Template Name: sidebarL.php
    */
    ?>
    if ( is_active_sidebar( 'sidebar-2' ) ) : ?>
    	<div id="primary" class="sidebar-container" role="complementary">
    		<div class="sidebar-inner">
    			<div class="widget-area">
    				<?php dynamic_sidebar( 'sidebar-2' ); ?>
    			</div><!-- .widget-area -->
    		</div><!-- .sidebar-inner -->
    	</div><!-- #tertiary -->
    <?php endif; ?>

    Should be this:

    <?php
    /*
    Template Name: sidebarL.php
    */
    if ( is_active_sidebar( 'sidebar-2' ) ) : ?>
    	<div id="primary" class="sidebar-container" role="complementary">
    		<div class="sidebar-inner">
    			<div class="widget-area">
    				<?php dynamic_sidebar( 'sidebar-2' ); ?>
    			</div><!-- .widget-area -->
    		</div><!-- .sidebar-inner -->
    	</div><!-- #tertiary -->
    <?php endif; ?>

    Note: This removes the first closing PHP tag, so the if ( is_active_sidebar( 'sidebar-2' ) ) : ?>
    will be parsed. I think that once you fix this error, it’ll probably make some of the rest of your page fall inline.

    One other oddity to me is that the code you posted for the Right sidebar has a template name of SidebarL.php, where I’d guess it would be SidebarR.php.

    I hope that helps!

    Thread Starter Major_1012

    (@major_1012)

    Yeah the misnaming had me confused for a while, especially with this file being listed as SidebarL in the dropdown but generating an error for sidebarR.

    I have since fixed those but posted the original code. The dropdown selector makes sense now.

    Dropped your code in and came up with a blank white page. There is a template for pages that brings in a header and footer on each new page. those do not show up either.

    This is all of the right sidebar php code. If some more code would help point me to it and I will be happy to post. I would post the website URL but these guys work with first responders and Law Enforcement and the owner would not be happy if I posted the URL on a public forum. Wish I could though…

    Is it safe to assume that since this does not work at all that I am safe to remove the <div> tags? I don not think they belong in a sidebar.php file, do they?

    Hey Major_1012,

    Looking more closely at the original code, I spotted something funny:

    <?php
    /*
    Template Name: sidebarL.php
    */
    if ( is_active_sidebar( 'sidebar-2' ) ) : ?>
    	<div id="primary" class="sidebar-container" role="complementary">
    		<div class="sidebar-inner">
    			<div class="widget-area">
    				<?php dynamic_sidebar( 'sidebar-2' ); ?>
    			</div><!-- .widget-area -->
    		</div><!-- .sidebar-inner -->
    	</div><!-- #tertiary -->
    <?php endif; ?>

    In the above sample, see that the final closing div has a comment saying it’s closing the #tertiary div. The corresponding opening div has an ID of primary. This is odd to me as I’d expect that your #primary div would be used for main content.

    If it is, then repeating the same div ID will definitely cause issues.

    You could check to see what IDs and classes your main content is using with Google Developer Tools (inspect element) or any other browser’s dev tools.

    I hope that helps!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Sidebar Repair woes!’ is closed to new replies.