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.ph
p 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.
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 :
PHP
CSS
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 !