wordpress hightlight Q
- Started
- Last post
- 18 Responses
- JamesBoynton
Hi guys, still battling through using Wordpress as a CMS... i have a sub-page which is highlighted when i am on but is there a way to also highlight the parent page?
cheers
james
- ckentish0
wordpress 3's new menu feature should handle this for you.
if not just create a custom template for those pages with it highlighted - its a hack but works for me.
- Continuity0
Funny, I just went through this a few days ago.
Anyway, WP automatically generates a class on links when they're the current active one. Here's a couple:
.current_page_item
.current_page_parentAll you need to do is style them according to your wishes in your CSS, like so:
.current_page_item a, .current_page_parent a {
color: #FFFFFF; !important
text-decoration: none; !important
}Now the parent category and the page the viewer is on is highlighted in the menu.
Done and done.
- Continuity, i love you. i realised i needed to solve this on a site tomorrow and wondered if possible. my beer tastes better suddenly.airey
- QBN delivers.®Continuity
- seldom™airey
- ckentish0
@continuity
Unfortunately this doesn't always work. If a post is under a sub category the parent category doesn't always highlight. Had this problem a few times...
- Continuity0
Ha. Hmmm. Could be; I've only used this on pages and page categories, as opposed to posts.
- airey0
which is why the selector is titled 'Page' as opposed to 'posts..
fucking idiots*.
but still, no doubt there's a post equivalent either there or in the mail.
*and i rely on you fuckers having the answers. so get it straight cunts. i don't have the brain to work any of it out.
- JamesBoynton0
Ahh had never spotted the .current_page_parent class... perfect!
Another problem, have created a page called blog to show latest blog posts.... its highlighted when on the blog page but is there a way to keep blog highlighted when on a blog article?
- JamesBoynton0
Continuity - I don't have any source code... and probably havent explained that... If i go to my news page which has a list of posts then news is highlighted in the menu, but if i click one of those posts obviously news is no longer highlighted... is there a way around it?
- acescence0
do you have news set up as a page or is it just a category?
- dbloc0
anyone know how to get rid of the line that separates posts?
- JamesBoynton0
acescence - I have a news page that shows the news (i changed the template to include the loop for only that category)... is there a better way to do it?
- acescence0
there are a few ways you can do it, I use that method a lot, create a page that has posts from a specific category. I usually build the nav manually though, rather than using the list_pages function. then it's a matter of using conditional tags to check what category you're in and highlighting that page in the nav...
if ( in_category( 'news' ) || is_page( 'news' ) {
echo 'highlight_class';
}
- dbloc0
If I want to get rid of all of the excess comment crap and leave just the content? What do I need to get rid of?
http://backgroundcollective.com/…
<?php get_header(); ?>
<div id="content">
<?php if (have_posts()) :the_post(); ?>
<h2 id="post-<?php the_ID(); ?>" class="pagetitle"><?php the_title(); ?></h2>
<div class="post">
<div class="entry">
<?php skimmed_milk_post_entry(); ?>
</div><!-- entry -->
<?php
$comments_open = 'open' == $post->comment_status;
$trackbacks_allowed = 'open' == $post->ping_status;if ($comments_open || $trackbacks_allowed || current_user_can('edit_page', $post->ID)) :
// show metadata here as long as it isn't blank
?>
<p class="postmetadata alt">
<?php skimmed_milk_post_comment_or_ping($comments_open, $trackbacks_allowed, $comments_open || $trackbacks_allowed); ?>
</p><?php endif; // end show metadata ?>
<!--
<?php trackback_rdf(); ?>
-->
</div><!-- post --><?php comments_template();
else : // no posts
skimmed_milk_something_not_found(__('Page not found', 'skimmed'));
endif; // end if have posts ?>
</div><!-- content -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
- JamesBoynton0
Ahhh cool, just taken a quick look, not sure if its possible with the wp_list_pages which i need to use for this site.... hmmm
- JamesBoynton0
Yeah i could try that but i think it would cause problems for the client who simply wants to be able to add/remove pages etc rather than having to mess with categories (which im also yet to understand!). Thanks for all the help guys.
- acescence0
ah ok, so presumably news is a special case and they won't be deleting that page, so use the exclude parameter of list pages to remove that page from the generated list and handle that case manually via the conditional tags as i pointed out above. the only catch is you'll have to put it before or after the list that wp spits out.
- JamesBoynton0
Ahhh good idea! Think i will give that a try! Thanks again for all the help, wordpress blows my mind...
- It is. I've done three implementations, now, and it always buggers me up.Continuity