mrsister
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: Assign CSS ID to submenuOk… I’m on my own here. But I did solve it, even if it I got no help.
For you guys who wants a menu where both parent and child (two levels) is highlighted, so your visitors to understand under what page they are, here’s the solution.
I create my menu in my header.php by a list. It looks like this…
<ul id="navlist"> <li<?php if (is_home()) { echo " id=\"active\""; } ?>><a href="<?php bloginfo('url') ?>">Home</a></li> <li<?php if (is_page('betalning')) { echo " id=\"active\""; } ?>><a href="<?php bloginfo('url') ?>/pagenr2">Page nr2</a></li></ul>That creates m main nav bar. As you can see, i echo the id=active, so I can style it in the CSS.
Now it’s time to define the children/subpages. It’s the same code I just earlier in my attemts.<?php if ($post->post_parent) { $children = wp_list_pages('title_li=&child_of='.$post->post_parent.'&echo=0&depth=1'); } else { $children = wp_list_pages('title_li=&child_of='.$post->ID.'&echo=0&depth=1'); } if ($children) { ?>As You can see, we define the children as $children, som now all we gotta do is to echo our children (if the parent have subpages).
<ul id="subnavlist"> <li><?php echo $children ?></li> </ul>Now, with my css, I style the id=”active” as
li#active a { background-color: #fc9; color: #000; }The children gets a class of current_page_item automaticly by WP, so I just style that class with li.current_page_item a and li.current_page_item a:hover
Over and out!
Forum: Fixing WordPress
In reply to: Nav Menu ProblemDo you have any plugins installed that generate the menu? Or do you have a hardcoded menu?
Show some code…
Best regards
MrSisterForum: Fixing WordPress
In reply to: Assign CSS ID to submenuSince there were thin response on the matter in question, I changed approach.
Now I generate my menu with flexi-pages. I created a widget-area within the functions.php-page. I paste code if someone needs a hand with that.
if ( function_exists('register_sidebar') ) { register_sidebar(array( 'before_widget' => '<li id="%1$s" class="widget %2$s">', 'after_widget' => '</li>', 'before_title' => '<h2 class="widgettitle">', 'after_title' => '</h2>', ));//My own widget-area is created with code from register_sidebar underneath, and stops at )); register_sidebar( array ( 'name' => 'Header Widget Area', 'id' => 'header-widget-area', 'before_widget' => '<li id="navlist" class="widget-container %2$s">', 'after_widget' => "</li>", 'before_title' => '<h5>', 'after_title' => '</h5>', ) );}With this done, the new widget-area should appear in your admin-area (where you drag and drop your widgets today).
But still, it does not show up anywhere in your WP, for your visitors to see i meen. It’s all backoffice til you call upon it.
I call upon my widget-area in my header, since it gonna be my menu. I do it like this:
<?php if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('Header Widget Area')) : ?>"> [ do default stuff if no widgets ] <?php endif; ?>And here is a larger peace of code, to show how the call-function operates. Just copy/paste.
<div class="description"><?php bloginfo('description'); ?></div> <div id="navcontainer"> <ul id="navlist"> <a href="<?php if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('Header Widget Area')) : ?>"> [ do default stuff if no widgets ] <?php endif; ?></a> </ul><!-- navlist --> </div><!-- navcontainer -->So, now You should be able to drag and drop any widget to you area, and it should appear in your header, or where you choosed to paste the <?php if (!function_exists…
Forum: Plugins
In reply to: Flexi Page Widget and sub-pagesGo with flexi-pages…
Forum: Plugins
In reply to: [Plugin: Flexi Pages Widget] current pageI agree, a parent link that’s always a “current_page_item” would be good.
Forum: Plugins
In reply to: [Flexi page]still not any success?
Forum: Themes and Templates
In reply to: How to Create new Widget AreaThis post sorted it out for me… Time to add status resolved?
Forum: Fixing WordPress
In reply to: Assign CSS ID to submenu*Bump again*
Is there someone that can help? All I wanna do is to assign CSS id=”subactive” to a submenu (child) if the child is current.
To me it seems that the problem is in me echo’ing all the children in all together (se `<?php echo $children ?>
`)
I think i need something like:
If post_id of specific child is chosen, then echo id=”subactive” on that specific child. (in order to highlight the tab in the menu).Would appreciate help.
Forum: Fixing WordPress
In reply to: Assign CSS ID to submenu*Bump*
Am I unclear?
Would appreciate help 🙂