Jump to content

Archived

This topic is now archived and is closed to further replies.

Luke

[Solved] Removing primary and secondary sidebars

Recommended Posts

Luke

Hi I am not using the primary or secondary sidebars, yet they are added to the page source code.

I'm using PL5 with PageLines.com child theme. Pages that use the default page template end up with code similar to the below even if you are not using the primary or secondary sidebars. I'm really focusing on improving speed and SEO so I want to remove any redundant code like this. 

If I use the PL5 page editor, then edit the wordpress content section it gives you options to select Select Sidebar 1 and Select Sidebar 2. If these aren't filled out then no redundant code should be added to the page. Alternatively an option to disable these sidebars would be nice.

I've searched online but could not find any code to remove the sidebars so any help would be appreciated as this seems like a PL5 issue to me.

<div class="plsb sb-primary pl-col-flex" data-bind="plsidebar:sb1">
        <div id="list_primary" class="sidebar_widgets  fix"><li id="search-2" class="widget widget_search"><form method="get" class="pl-search-form pl-searcher" onsubmit="this.submit();return false;" action="http://www.mydomain.com/" ><fieldset><span class="btn-search"><i class="pl-icon pl-icon-search"></i></span><input type="text" value="" name="s" class="search-field" placeholder="Search" /></fieldset></form></li>
<li id="recent-comments-2" class="widget widget_recent_comments"><h2 class="widgettitle">Recent Comments</h2>
<ul id="recentcomments"></ul></li>
<li id="archives-2" class="widget widget_archive"><h2 class="widgettitle">Archives</h2>
		<ul>
				</ul>
		</li>
<li id="categories-2" class="widget widget_categories"><h2 class="widgettitle">Categories</h2>
		<ul>
<li class="cat-item-none">No categories</li>		</ul>
</li>
<li id="meta-2" class="widget widget_meta"><h2 class="widgettitle">Meta</h2>
			<ul>
			<li><a rel="nofollow" href="http://www.mydomain.com/wp-admin/">Site Admin</a></li>			<li><a rel="nofollow" href="http://www.mydomain.com/wp-login.php?action=logout">Log out</a></li>
			<li><a href="http://www.mydomain.com/feed">Entries <abbr title="Really Simple Syndication">RSS</abbr></a></li>
			<li><a href="http://www.mydomain.com/comments/feed">Comments <abbr title="Really Simple Syndication">RSS</abbr></a></li>
			<li><a href="https://wordpress.org/" title="Powered by WordPress, state-of-the-art semantic personal publishing platform.">WordPress.org</a></li>			</ul>
			</li>
</div>    </div>
                <div class="plsb sb-secondary pl-col-flex" data-bind="plsidebar:sb2">
        <div id="list_secondary" class="sidebar_widgets  fix">
        <li class="widget"><div class="widget widget-default setup_area no_secondary">
            <div class="widget-pad">
            <h3 class="widgettitle">No Widgets</h3>
            <p class="fix">"Secondary" needs some <a href="http://www.mydomain.com/wp-admin/widgets.php">widgets</a>.
            </p>
            </div>
        </div></li>

    </div>    </div>

 

Share this post


Link to post
Share on other sites
Andrew

ok well, its true this is coming from the Framework theme, there are two different things you could do...

  1. My suggested approach that you leave things the way they are, and just remove all 'widgets' via WP admin from the sidebars. This hidden content won't against you with google and since you don't have anything in them, there won't be any Database queries to slow your site.
  2. Deregister the sidebars with unregister_sidebar ... the IDs would be 'primary' and 'secondary' and you'd need a hook.

Share this post


Link to post
Share on other sites
Luke

Thanks deregistering the sidebars largely worked. However I'm now left with the below code. Is there anyway to get rid of the remaining code so I'm not left with those redundant h3 tags and the links pointing to widgets.php

            <div class="plsb sb-primary pl-col-flex" data-bind="plsidebar:sb1">
        <div id="list_primary" class="sidebar_widgets  fix">
        <li class="widget"><div class="widget widget-default setup_area no_primary">
            <div class="widget-pad">
            <h3 class="widgettitle">No Widgets</h3>
            <p class="fix">This sidebar needs some <a href="http://www.mydomain.com/wp-admin/widgets.php">widgets</a>.
            </p>
            </div>
        </div></li>

    </div>    </div>
                <div class="plsb sb-secondary pl-col-flex" data-bind="plsidebar:sb2">
        <div id="list_secondary" class="sidebar_widgets  fix">
        <li class="widget"><div class="widget widget-default setup_area no_secondary">
            <div class="widget-pad">
            <h3 class="widgettitle">No Widgets</h3>
            <p class="fix">This sidebar needs some <a href="http://www.mydomain.com/wp-admin/widgets.php">widgets</a>.
            </p>
            </div>
        </div></li>

    </div>    </div>

 

Share this post


Link to post
Share on other sites
Andrew

I'm going to adjust it so that the output above is only shown to admin users while they are logged in,  that will come in the next update ... i recommend just leaving it.

Share this post


Link to post
Share on other sites
Luke

That's a great idea, thanks Andrew. I'll wait till it's released in a future update.

Share this post


Link to post
Share on other sites
Luke

Hi Andrew, I'm still seeing this redundant code on sites so I wondered if this might make it into an update soon?

I've been able to unregister the sidebars and they no longer show in the Widgets section, however the code still remains. Any suggestions for also removing the code front end?

Share this post


Link to post
Share on other sites
Luke

Following up on this from last week to see if anyone might have a solution to this issue.

Also does anyone at Pagelines know if there will be an update released soon with this redundant code removed by default?

Share this post


Link to post
Share on other sites
Ray

@Luke  You can always get rid of it via js, example:  

Screenshot: https://cl.ly/loTu

Code:

<script>
jQuery( document ).ready(function($) {
	var primary_sidebar = $('.plsb.sb-primary');
    var secondary_sidebar = $('.plsb.sb-secondary');
    
  	if( primary_sidebar || secondary_sidebar ){
    	primary_sidebar.remove();
    	secondary_sidebar.remove();
  	}
    
});

</script>

 

Share this post


Link to post
Share on other sites

×