Solved

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

Posted on 2010-11-23
6
489 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

734 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