当前位置: 动力学知识库 > 问答 > 编程问答 >

php - Remove sidebar and replay from wordpress post page

问题描述:

I am looking for help to remove "junk" widgets from my wordpress website. Website theme is Zerif Lite and on every page so far there was no sidebar,however when I make a new post there is alot of junk (sidebar,who posted it,when,how entry was tagged and replay option).

I tried removing it from appearance->widgets and it didnt work and theme customization for widgets is locked for lite version.

So for start I 1st want to remove sidebar that include search,archives and meta.Only thing that worked so far was blanking out sidebar.php that include:

<div id="secondary" class="widget-area" role="complementary">

<?php if ( ! dynamic_sidebar( 'sidebar-1' ) ) : ?>

<aside id="search" class="widget widget_search">

<?php get_search_form(); ?>

</aside>

<aside id="archives" class="widget">

<h2 class="widget-title"><?php _e( 'Archives', 'zerif-lite' ); ?></h2>

<ul>

<?php wp_get_archives( array( 'type' => 'monthly' ) ); ?>

</ul>

</aside>

<aside id="meta" class="widget">

<h2 class="widget-title"><?php _e( 'Meta', 'zerif-lite' ); ?></h2>

<ul>

<?php wp_register(); ?>

<li><?php wp_loginout(); ?></li>

<?php wp_meta(); ?>

</ul>

</aside>

<?php endif; ?>

</div><!-- #secondary -->

However when I did that sidebar was removed,but space it took was blank,meaning post itself was only using 2/3 of page.

To get you to see for your self here are links to site (its in serbian,ignore that):

website and:

new post, this you can only see with this link,its where problem is

So if anyone can help me remove all that and make page clean I would be very greatfull. Thanks

网友答案:

The problem is css

Here is the solution (only if you dont use sidebar anywhere in your site)

Change the width of your content container, maybe right now is set to 70%(remaining 30% is for sidebar) to 100%.

If you plane to use sidebar, then you need set a conditional class in your functions.php:

function custom_body_classes( $classes ) {
// Adds a class of nosidebar to sites without active sidebar.
if ( ! is_active_sidebar( 'sidebar-1' ) ) {
$classes[] = 'nosidebar';
}
return $classes;
}
add_filter( 'body_class', 'custom_body_classes' );

Then only customize the css with the new class. Ex:

.content .nosidebar {
width:100%
}

Cheers

分享给朋友:
您可能感兴趣的文章:
随机阅读: