Remove sidebar and replay from wordpress post page - php

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

Related

Suppress Meta Log In, Log out from pages when the theme has no reference to it

I am using a theme (ward) that has no reference to the Meta / Site Admin / Log Out but I am still seeing it at the bottom of every page/post. I have looked all php files from the theme and I cannot see any mention to that.
How do I get rid of this? Is there any hook to get rid of this?
edit
This is my Meta on the appearance widgets:
But as you can see I have nothing on the first sidebar or home page
There is, in sidebar.php:
<?php
/**
* The first/left sidebar widgetized area.
*
* If no active widgets in sidebar, alert with default login
* widget will appear.
*
* #since 1.0.0
*/
?>
<div id="secondary" <?php bavotasan_sidebar_class(); ?> role="complementary">
<?php if ( ! dynamic_sidebar( 'sidebar' ) ) : ?>
<?php if ( current_user_can( 'edit_theme_options' ) ) { ?>
<div class="alert alert-warning"><?php printf( __( 'Add your own widgets by going to the %sWidgets admin page%s.', 'ward' ), '', '' ); ?></div>
<?php } ?>
<aside id="meta" class="widget">
<h3 class="widget-title"><?php _e( 'Meta', 'ward' ); ?></h3>
<ul>
<?php wp_register(); ?>
<li><?php wp_loginout(); ?></li>
<?php wp_meta(); ?>
</ul>
</aside>
<?php endif; ?>
</div><!-- #secondary.widget-area -->
It's the wp_loginout() that's causing it.

Add echo to my wordpress sidebar for non-connected users

i have Nice Login Widget which does not have any link to the registration page for non-members (simple visitors). I would like to visualize the Inscription link on the sidebar, just under the login widget but NOT anymore when someone is logged in !
The idea is that i will visualize the link with echo and by its css i could position it absolute.
I do not know anything about php, i tried to add some codes in my sidebar.php file but it does not work :
The sidebar.php is a classic twentyeleven theme :
<?php
if ( 'content' != $current_layout ) :
?>
<div id="secondary" class="widget-area" role="complementary">
<?php if ( ! dynamic_sidebar( 'sidebar-1' ) ) : ?>
<?php
if ( is_user_logged_in() ) {
echo '';
else
echo '<a class="inscrip-link" href="http://www.igorlaszlo.com/test/register/">Inscription</a>';
?>
<aside id="archives" class="widget">
<h3 class="widget-title"><?php _e( 'Archives', 'vihegay' ); ?></h3>
<ul>
<?php wp_get_archives( array( 'type' => 'monthly' ) ); ?>
</ul>
</aside>
<aside id="meta" class="widget">
<h3 class="widget-title"><?php _e( 'Meta', 'vihegay' ); ?></h3>
<ul>
<?php wp_register(); ?>
<li><?php wp_loginout(); ?></li>
<?php wp_meta(); ?>
</ul>
</aside>
<?php endif; // end sidebar widget area ?>
</div><!-- #secondary .widget-area -->
<?php endif; ?>
My added codes in above codes are :
<?php
if ( is_user_logged_in() ) {
echo '';
else
echo '<a class="inscrip-link" href="http://www.igorlaszlo.com/test/register/">Inscription</a>';
?>
Then i would add the css to the link class inscrip-link :
.inscrip-link {
position:absolute;
top:300px;
left: 30%;
z-index:1;
}
Can someone tell me how to do this ? (I accept better solution as well !:))
Your code seems to be missing a few curly brackets.
<?php
if ( !is_user_logged_in() )
{
echo '<a class="inscrip-link" href="http://www.igorlaszlo.com/test/register/">Inscription</a>';
}
?>
I have changed your code a bit. The register link will only show when a user is not logged in.
Finally i found a better solution for my case to be able to add my link with relative position to the sidebar... if someone has the same problem :
I added a text widget with my inscription link (#text-7) under my login widget.
In sidebar.php I added a widget with the same id (#text-7) which gives a classe to the body when users are logged-in (see php codes below).
In the style.css i give style to the #text-7 widget and i display:none when the body class is "logged-in" (see codes below).
PHP
<aside <?php echo (is_user_logged_in() ? 'class="widget widget_text logged-in"' : ''); ?> id="text-7" class="widget">
<h3 class="widget-title"></h3>
<div class="center">Inscription</div>
</aside>
CSS
#text-7 {position:relative;margin: -50px auto 30px;z-index:1;}
.logged-in #text-7 {display: none;}
Together with my personal class, i also added all other classes to the widget what a widget should have (widget and widget_text) because if not, it did not work for me... maybe it is just a "handmade" code but it work fine !

How to add news Ticker on home page only

I installed a news ticker plugin,
Then I added necessary function/code in sidebar.php
<!-- BEGIN: #secondary -->
<div id="secondary" class="g1-sidebar widget-area" role="complementary">
<h3>Latest News</h3>
<div id="news">
<?php if ( function_exists('insert_newsticker') ) { insert_newsticker(); } ?>
</div>
.......
.........
</div>
Now news ticker coming on all page's sidebar.
But i want it to add in only home page sideabr.
Is there any way to do this, so if side bar is primary/home
then only display news ticker...
use is_front_page() for the front page check.
if( is_front_page() && function_exists('insert_newsticker') ){
insert_newsticker();
}
More Information is_front_page()
Updated according to Comments:
<div id="secondary" class="g1-sidebar widget-area" role="complementary">
<?php if( is_front_page() ): ?>
// Your h3 tag here
<?php endif; ?>
<h3>Latest News</h3>
<div id="news">
use 'is_home' function more detail: http://codex.wordpress.org/Function_Reference/is_home
The $_SERVER["REQUEST_URI] will contain the uri of the current address so if you compare that to the homepage ("/") it will allow you to see whether to insert it. You could also fairly easily add support for other pages on your site if you decided to add the plugin there at a later date.

Underscores Wordpress Theme - Adding second sidebar

Stared a Wordpress site using Underscores theme (_s)
I have got one sidebar working but want to make a second one to be on the same page. (containing different widgets)
I have added the new sidebar to the functions.php and it appears in the Wordpress login screen and i can drop widgets into it. However, I can't get it to show on the actual webpage. (the first sidebar is working fine)
Anyone know how to do this or know a tutorial...
Thanks
You'll need to edit the "sidebar.php" file in your theme folder. It should normally be:
<div id="secondary" class="widget-area" role="complementary">
<?php do_action( 'before_sidebar' ); ?>
<?php if ( ! dynamic_sidebar( 'sidebar-1' ) ) : ?>
<?php endif; // end sidebar-1 widget area ?>
</div><!-- #secondary -->
You will need to add another if statement that looks out for the other sidebar. Be sure to reference it by whatever you used in the functions.php file.
If you want it to appear below the current sidebar, just be sure to add it before closing the 'div' so it will still be in the same column. I used 'sidebar-lower':
<div id="secondary" class="widget-area" role="complementary">
<?php do_action( 'before_sidebar' ); ?>
<?php if ( ! dynamic_sidebar( 'sidebar-1' ) ) : ?>
<?php endif; // end sidebar-1 widget area ?>
<?php if ( ! dynamic_sidebar( 'sidebar-lower' ) ) : ?>
<?php endif; // end sidebar-lower widget area ?>
</div><!-- #secondary -->

trying to understand page.php in Wordpress "application" theme

I'm trying to set up a commercial website using Wordpress and I'm experimenting with different themes. I like "application", but I would like to get rid of the sidebar in "pages" (as opposed to "posts"). So I figured I would edit the template. I believe that is the file "page.php." I'm just learning PHP so some of this is mysterious. My immediate question is how to get rid of the sidebar, but more important than that, I just want to ask some basic questions about the structure of this file.
Here is page.php in the themes/application directory:
<?php get_header(); ?>
<!--content-->
<div id="content">
<div id="left-col">
<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
<div class="post-head-page">
<?php if ( is_front_page() ) { ?>
<h1><?php the_title(); ?></h1>
<?php } else { ?>
<h1><?php the_title(); ?></h1>
<?php } ?>
</div><!--post-heading end-->
<div class="post-entry">
<?php the_content(); ?>
<div class="clear"></div>
<?php wp_link_pages( array( 'before' => '' . __( 'Pages:', 'application' ), 'after' => '' ) ); ?>
</div><!--post-entry end-->
<?php comments_template( '', true ); ?>
<?php endwhile; ?>
</div> <!--left-col end-->
<?php get_sidebar(); ?>
</div> <!--content end-->
</div>
<!--wrapper end-->
<?php get_footer(); ?>
Basic questions:
Does this represent the structure of both Pages and Posts? I only care about Pages (I won't use posts in my website; it's a commercial website)
I'm told that when I create a custom template, I have to conform to the structure of the pages in my theme. What is the "structure" of this file? How can I tell what that is for my theme?
And if you can see a simple way to remove the sidebar let me know.
This file only represents the structure for pages. Not for posts. To see what templates are used for what content, see this documentation, including a nice diagram.
I believe they mean that you'll need to keep the same html/php structure as in this file. When creating custom page templates, duplicate this file and then start adjusting it to your needs.
Remove the line with get_sidebar() to remove the sidebar.
Hope that helps!

Categories