Jump to content

Wordpress Sidebar Question


digitallookout

Recommended Posts

Hi,

 

I have a problem with the sidebar on my wordpress blog and dont ave the php skillls to solve ti so I was hoping one of you kind people could help me out!  :)

 

I only want my blogroll to display on the homepage of the blog and not sitewide as it does at present.  Looking at the code it looks to me like the should already be the case as it references - if(is_home)) get links list - which logically to me suggests that this should only display on the homepage but it is displaying sitewide at present.

 

The full sidebar code is below, I have highlighted the section I believe is dealing with this, any help is greatly appreciated!

 

Rob

 

<div id="sidebar">

<ul>

<?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar() ) : else : ?>

  <?php if(is_home()) {?>

<?php }?>

<li>

  <h2><?php _e('Search'); ?></h2>

<form id="searchform" method="get" action="<?php bloginfo('siteurl')?>/">

<input type="text" name="s" class="textbox" value="<?php echo wp_specialchars($s, 1); ?>" />

<input id="btnSearch" type="submit" name="submit" value="<?php _e('Search'); ?>" />

</form>

  </li>

  <li>

    <h2>

      <?php _e('Categories'); ?>

    </h2>

    <ul>

      <?php wp_list_cats('optioncount=0&hierarchical=1');    ?>

    </ul>

  </li>

  <li>

    <h2>

      <?php _e('Monthly'); ?>

    </h2>

    <ul>

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

    </ul>

  </li>

  <li>

    <h2><?php _e('Pages'); ?></h2>

    <ul>

      <?php wp_list_pages('title_li=' ); ?>

    </ul>

  </li>

  <?php if(is_home()) {?>

  <?php get_links_list(); ?>

  <li>

<h2>Meta</h2>

<ul>

<?php wp_register(); ?>

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

<li><a href="http://validator.w3.org/check/referer" title="This page validates as XHTML 1.0 Transitional">Valid <abbr title="eXtensible HyperText Markup Language">XHTML</abbr></a></li>

<li><a href="http://gmpg.org/xfn/"><abbr title="XHTML Friends Network">XFN</abbr></a></li>

<li><a href="http://wordpress.org/" title="Powered by WordPress, state-of-the-art semantic personal publishing platform.">WordPress</a></li>

<?php wp_meta(); ?>

</ul>

  </li>

  <?php }?>

  <?php endif; ?>

</ul>

</div>

<!-- CLOSE sidebar-->

<div class="clear"></div>

 

Link to comment
Share on other sites

Well, the if(is_home) code is being closed instantly

 

<?php if(is_home()) {?>

<?php }?>

 

If you move that second line after the closing end of the code (equaly placed as the openning tag in the code hierachy) it should work, but you will prob be better off using a wordpress forum

Link to comment
Share on other sites

If you remove <?php get_links_list(); ?>  and it removes your blogroll...good...if not...find what does.  but i think your right  <?php get_links_list(); ?>    mines  <?php get_bookmarks(); ?>

I always use the default theme...cause its clean and you can bend it to do whatever you want.

 

Now  If you want your blog roll to show up lets say on one of you static Pages, you could do this inside of your sidebar.php....I took the code form what you posted

 


<li>
    <h2><?php _e('Pages'); ?></h2>
    <ul>
      <?php wp_list_pages('title_li=' ); ?>
    </ul>
  </li>   
  <?php if(is_home()) {?>

<?php
$page_id = isset($_GET['page_id']) ? $_GET['page_id'] : '';
switch ($page_id)
{
	case '2':
	{
		include("incSidebar.php");
		break;
	}
	default:
	{
		include("includenothing.php");
		break;
	}
}
?>

  <li>
      <h2>Meta</h2>
      <ul>
         <?php wp_register(); ?>
         <li><?php wp_loginout(); ?></li>
         <li><a href="http://validator.w3.org/check/referer" title="This page validates as XHTML 1.0 Transitional">Valid <abbr title="eXtensible HyperText Markup Language">XHTML</abbr></a></li>
         <li><a href="http://gmpg.org/xfn/"><abbr title="XHTML Friends Network">XFN</abbr></a></li>
         <li><a href="http://wordpress.org/" title="Powered by WordPress, state-of-the-art semantic personal publishing platform.">WordPress</a></li>
         <?php wp_meta(); ?>

 

If you add this code in...basically you are looking for the ID of your page, and if it = 2 (case 2) include  incSidebar.php

If its not the page ID 2 display the default includenothing.php

 

then save 2 files

incSidebar.php  and here's your chunk of code

<?php get_links_list(); ?>

 

and

 

includenothing.php   

<?php //this is nothing ?>

 

which is a comment....i don't know how proper this is...but it works

 

make sure you put the 2 files in the same dir. of your sidebar.php

 

hope this helps

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.