WordPress.org

Forums

Contextual Related Posts
[resolved] Class for post/page (13 posts)

  1. Danny Albeck
    Member
    Posted 1 year ago #

    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!

    http://wordpress.org/plugins/contextual-related-posts/

  2. Ajay
    Member
    Plugin Author

    Posted 1 year ago #

    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

  3. Danny Albeck
    Member
    Posted 1 year ago #

    Ajay,

    It is combined in 1 widget area. So occasionally the pages and posts are mixed in together.

  4. Ajay
    Member
    Plugin Author

    Posted 1 year ago #

    I understand now. You mean each list item?

  5. Danny Albeck
    Member
    Posted 1 year ago #

    Yes that's correct. That way I could just use CSS to hide the date on any list item with a class of page.

  6. Ajay
    Member
    Plugin Author

    Posted 1 year ago #

    It hasn't been implemented yet, but I can put this on the list of things to do.

  7. Danny Albeck
    Member
    Posted 1 year ago #

    Any ideas for a quick solution on this?

    Thanks!

  8. Ajay
    Member
    Plugin Author

    Posted 1 year ago #

    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.

  9. Danny Albeck
    Member
    Posted 1 year ago #

    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.

  10. Ajay
    Member
    Plugin Author

    Posted 1 year ago #

    Danny, is this for all pages or just a specific one?

    What happens when you revert the changes?

  11. Danny Albeck
    Member
    Posted 1 year ago #

    Happened with about 10 pages that I clicked through. I put back the original code and it displayed the related content again.

  12. Ajay
    Member
    Plugin Author

    Posted 1 year ago #

    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.

  13. Danny Albeck
    Member
    Posted 1 year ago #

    Ok, thank you for your help!

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Contextual Related Posts
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic