Hi,
I’m working on a site with a news section using a ready made theme. I’d like the news archive links to only display on the news page, on a news post, or in an archive (which will be by category only). Below is the offending code from sidebar.php. This checks if there are any widgets activated for the sidebar, and if there aren’t, displays the archive links (by category). Unfortunately, my PHP skills/knowledge are virtually non existent, hence the appeal for help!
You can see I’ve added a tentative ‘else(is_page(’##‘))’ - in theory this ID number is the number for the news index page i.e. if this is the news index, show the archive links; if not, don’t! I do also want widgets in the sidebar to show up on the news page, but I’m just trying to get this conditional code to work first, which it doesn’t (probably no surprise to you if you’re reading). With this code I get the news archive and any widgets on every page of the site.
I’m aware that ‘is_page’ won’t work inside the loop, but the loop is called in the page template and is finished by the time sidebar.php is called (is that right?!)
<?php
if ( ! dynamic_sidebar( 'primary-widget-area' ) ) ;
else ( is_page('27'));
?>
<li id="archives" class="widget-container">
<h3 class="widget-title"><?php _e( 'Archives', 'localize' ); ?></h3>
<ul>
<?php wp_list_categories('orderby=name&show_count=1'); ?>
</ul>
</li>
<li id="meta" class="widget-container">
<h3 class="widget-title"><?php /*_e( 'Meta', 'localize' ); ?></h3>
<ul>
<?php wp_register(); ?>
<li><?php wp_loginout(); ?></li>
<?php wp_meta(); */?>
</ul>
</li>
</ul>
Thanks for any suggestions