Solved

wordpress - how to get rid of parent menu item in sidebar

Posted on 2010-11-23
6
478 Views
Last Modified: 2012-08-13
Notice on this page how the "In The News" section is highlighted.

http://pacificcenterplasticsurgery.com/newsite/news/

There is also an "In the News" header at the top of the sidebar:
<h2 class="sidebartitle">In the News</h2>

I don't want this h2 to show when I go to the "In the News" page. I just want the "In the News" link to show. The one that is currently below the "Plasticos Foundation" link in the sidebar.

Thanks!
0
Comment
Question by:phillystyle123
  • 4
  • 2
6 Comments
 
LVL 17

Expert Comment

by:jrm213jrm213
ID: 34200330
edit sidebar.php to not display that h2 if on that page...

can you post the contents or upload your sidebar.php?
0
 

Author Comment

by:phillystyle123
ID: 34200549
Thanks for the reply,

sidebar attached. Actually, what I'd really like to do is to list a page that is using "In the News" as a parent underneath the "In the News" link so if you were on this page:

http://pacificcenterplasticsurgery.com/newsite/blog/

<h2 class="sidebartitle">In the News</h2> wouldn't appear and the sidebar would output as follows:

Plasticos Foundation
In the News
>Articles (In the News is the parent)
Read Our Blog

Perhaps I need to make the "In the News link go away instead?
<ul>
  <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() ) : ?>
    <?php
    global $notfound;
    if (is_page() and ($notfound != '1')) {
        $current_page = $post->ID;
        while($current_page) {
            $page_query = $wpdb->get_row("SELECT ID, post_title, post_status, post_parent FROM $wpdb->posts WHERE ID = '$current_page'");
            $current_page = $page_query->post_parent;
        }
        $parent_id = $page_query->ID;
        $parent_title = $page_query->post_title;
	?>
	
	
	<?php
        // if ($wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_parent = '$parent_id' AND post_status != 'attachment'")) {
        if ($wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_parent = '$parent_id' AND post_type != 'attachment'")) {
    ?>

    <?php } } ?>
	
	
		<?php wp_list_categories('sort_column=name&optioncount=1&hierarchical=0&title_li=<h2 class="sidebartitle">' . __('Categories') . '</h2>'); ?>
    <li class="widget">
      <h2 class="sidebartitle"><?php _e('Archives'); ?></h2>
	  
      <ul class="list-archives">
        <?php wp_get_archives('type=monthly'); ?>
      </ul>
	 
    </li>
    <li class="widget">
      <h2 class="sidebartitle"><?php _e('Links'); ?></h2>
      <ul class="list-blogroll">
        <?php 
			$links = get_bookmarks('orderby=name&order=ASC&limit=-1'); 
			foreach($links as $link){
				echo '<li><a href="'.$link -> link_url.'">'.$link -> link_name.'</a></li>';
			}
		?>
      </ul>
    </li>
	<li class="widget">
      <h2 class="sidebartitle">Meta</h2>
      <ul class="list-meta">
		<li><a href="<?php bloginfo('rss2_url'); ?>" title="<?php _e('Syndicate this site using RSS'); ?>"><?php _e('<abbr title="Really Simple Syndication">RSS</abbr>'); ?></a></li>
		<li><a href="<?php bloginfo('comments_rss2_url'); ?>" title="<?php _e('The latest comments to all posts in RSS'); ?>"><?php _e('Comments <abbr title="Really Simple Syndication">RSS</abbr>'); ?></a></li>
		<li><a href="http://mythem.es/" title="mythem.es">My Themes</a></li>
		<?php wp_meta(); ?>
      </ul>
    </li>
  <?php endif; ?>
 </ul>
<!--/sidebar -->

Open in new window

0
 
LVL 17

Expert Comment

by:jrm213jrm213
ID: 34200630
ok so to get rid of the <h2> at the top of the sidebar

remove

&title_li=<h2 class="sidebartitle">' . __('Categories') . '</h2>'

from the call to wp_list_categories at linie 24 above



In order to do what you are specifying as far as listing pages under a specific category, you can do that but there isn't a function to just do it, you will have to get your data and then run some replaces to inject the pages into the correct spot.
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:phillystyle123
ID: 34200690
i only want to get rid of it for the "In the News" page - is there some sort of conditional I can use ala
<?php if ( is_front_page() ) { ?>?
0
 
LVL 17

Expert Comment

by:jrm213jrm213
ID: 34200720
unfortunately, not that I know of. You will most likely need to build the menu yourself using get_categories
0
 
LVL 17

Accepted Solution

by:
jrm213jrm213 earned 500 total points
ID: 34200802
oh you know what you could do though...

you could use

if is_category to surround the whole statement and use two different wp_list_categories calls. I initially thought you meant a conditional for inside the wp_list_categories parameter string...

if is_category(['id,title or slug  of your category'])
{
   wp_list_categories('sort_column=name&optioncount=1&hierarchical=0');
}else
{
wp_list_categories('sort_column=name&optioncount=1&hierarchical=0&title_li=<h2 class="sidebartitle">' . __('Categories') . '</h2>');
}
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
.htaccess file settings 4 36
Page showing diff display 4 22
PHP loop not working 4 33
writting html or javascript in PHP 8 14
I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The purpose of this video is to demonstrate how to Test the speed of a WordPress Website. Site Speed is an important metric of a site’s health. Slow site speed can result in viewers leaving your site quickly and not seeing your content. This…
The viewer will learn how to count occurrences of each item in an array.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now