Class for post/page
-
I was wondering if its possible to create a function or some method of labeling each li item so if its a post has a class of post and if its a page has a class of page.
I need to remove the date from showing up only on pages but want to keep it on posts.
Thanks!
-
Danny,
it isn’t there right now. Would your theme have a separate class for the content area for post or page?
If so, you could probably use that. So something like:
.class_page .crp_related
and
.class_post .crp_related
Ajay,
It is combined in 1 widget area. So occasionally the pages and posts are mixed in together.
I understand now. You mean each list item?
Yes that’s correct. That way I could just use CSS to hide the date on any list item with a class of page.
It hasn’t been implemented yet, but I can put this on the list of things to do.
Any ideas for a quick solution on this?
Thanks!
I don’t see any easy solution for this. You’ll need to edit contextual-related-posts.php
You could try something like this for now:
Line 104: change from:$output .= $crp_settings['before_list_item'];
to
$output .= str_replace("%posttype%",get_post_type( $result->ID ),$crp_settings['before_list_item']);
Then in your Output Options tab for “HTML to display before each item”, you can change it to
<li class="%posttype%">
This should replace %posttype% with the actual post type i.e. post or page and you can apply your CSS styles then.
Do let me know if this works for you.
After making the edits I get the following now on my page:
“No related posts found”
Thank you for taking the time to help me out with this.
Danny, is this for all pages or just a specific one?
What happens when you revert the changes?
Happened with about 10 pages that I clicked through. I put back the original code and it displayed the related content again.
Danny,
I’ll need to test the above code on my servers in detail to see what can work.
I’m not exactly sure what’s going wrong, but most likely its messing up the algorithm.
Ok, thank you for your help!
- The topic ‘Class for post/page’ is closed to new replies.