WordPress.org

Ready to get started?Download WordPress

Forums

Customizr
[resolved] Short posts = no comment? (40 posts)

  1. chappie
    Member
    Posted 2 months ago #

    When posts are very short - like several here - the post index page doesn't include a link to the post page so there is no obvious way for people to leave a comment. If they click on the blog link in the sidebar, they will find the right page to post a comment - but presumably those sidebar links will scroll out of sight over time.

    Am I missing something? TIA.

  2. chappie
    Member
    Posted 2 months ago #

    From here, it looks as though the answer would be to include a "Comment" link at the bottom of each post excerpt on the index page. But I'm usually wrong.

  3. d4z_c0nf
    Member
    Posted 2 months ago #

    Hi chappie, mm don't think it's about the shortness, is about those post types which haven't a title (the title isn't displayed)..

  4. chappie
    Member
    Posted 2 months ago #

    I see…but surely if one such post was 10000 words long, there would be a link to it as it would overflow the excerpt length?

    Meanwhile, it's possible for people to post a comment (by clicking on the post link in the sidebar) - which no-one else will ever see once the sidebar link scrolls out of view. Indeed, during testing, someone did just that and it presents me with a problem.

    So is the solution never to use those post types? (Not elegant imho.)

    Or is there a way to add a Comment button or link to the excerpts of all such post types?

  5. d4z_c0nf
    Member
    Posted 2 months ago #

    For those kind of posts type the whole content should be printed, with a "Continue reading >>" text for the tag more, do you use the tag more there? That will insure you a link to the post.. and to me it seems the best option, instead of a comment link .. which is possible anyway :D

  6. chappie
    Member
    Posted 2 months ago #

    I don't think there's a problem with posts longer than the excerpt length. But I do want to provide a View/Add Comments option (linking to the post's own page) for posts which are complete within the excerpt.

    I guess I could add something manually to the end of every short post or relevant post type - but the site owner won't be able to do that when she's on her own…

  7. d4z_c0nf
    Member
    Posted 2 months ago #

    Well chappie I didn't said it depended on the shortness, I said exactly exactly the opposite :)
    I said that for those particular post types customizr shows the content and not the excerpt. Also if you use the tag more into those post contents you should see a link which points to the articles. That's what I said :)

    Said so, lunch time, if you still want this "comment link" for those post types I will be back with the code later.. ;)

  8. d4z_c0nf
    Member
    Posted 2 months ago #

    So chappie this is the code to have that link you wanted in those post types:

    add_filter('the_content', 'add_leave_a_comment');
    function add_leave_a_comment($content){
        $post_formats = array('quote', 'aside', 'status', 'link');
        if ( ! in_array(get_post_format(), $post_formats ) )
            return $content;
    
        $leave_comment_string = __('Leave a comment');
        $leave_comment_link = sprintf('<p class="chappie-comments-link"><a href="%1$s#comments" title="%2$s %3$s">%4$s</a></p>',
                                  is_singular() ? '' : get_permalink(),
                                  __( 'Comment(s) on' , 'customizr' ),
                                  get_the_title(),
                                  $leave_comment_string
                                  );
        return $content . $leave_comment_link;
    }

    Then style that p ;)

    Hope this helps.

  9. ElectricFeet
    Member
    Posted 2 months ago #

    The post types you're talking about are "asides". They are meant to be just a quick few words.

    Maybe you would be better using a link post format.

  10. d4z_c0nf
    Member
    Posted 2 months ago #

    Mmm but that is to show links, then he should wrote links in the post contents. Am I wrong?
    Anyway @chappie , sorry I forgot to exclude that link when you display the post (post page), this is better:

    add_filter('the_content', 'add_leave_a_comment');
    function add_leave_a_comment($content){
        if ( is_singular() )
            return $content;
        $post_formats = array('quote', 'aside', 'status', 'link');
        if ( ! in_array(get_post_format(), $post_formats ) )
            return $content;
    
        $leave_comment_string = __('Leave a comment');
        $leave_comment_link = sprintf('<p class="chappie-comments-link"><a href="%1$s#comments" title="%2$s %3$s">%4$s</a></p>',
                                  get_permalink(),
                                  __( 'Comment(s) on' , 'customizr' ),
                                  get_the_title(),
                                  $leave_comment_string
                                  );
        return $content . $leave_comment_link;
    }
  11. chappie
    Member
    Posted 2 months ago #

    Thanks chaps: I've been afk for a few hours but will play with this code now. It would be superdooperextragood™ if it could include a little bubble with a number inside to show if there any comments to read…?

  12. chappie
    Member
    Posted 2 months ago #

    The post types you're talking about are "asides". They are meant to be just a quick few words.

    I realise this ElectricFeet - but once a link shows in the sidebar then anyone is able to post a comment and they don't know they aren't supposed to! So I have to cater for that possibility, n'est-ce pas?

  13. d4z_c0nf
    Member
    Posted 2 months ago #

    add_filter('the_content', 'add_leave_a_comment');
    function add_leave_a_comment($content){
        if ( is_single() || ! comments_open() ){
            return $content;
        }
        $post_formats = array('quote', 'aside', 'status', 'link');
        if ( ! in_array(get_post_format(), $post_formats ) )
            return $content;
    
        /* mostly copied from class-content-hedings */
        //adds filters for comment bubble style and icon
        $bubble_comment = ( get_comments_number() > 0 ) ? sprintf('<span class="fs1 icon-bubble"></span><span class="inner">%1$s</span>',
                                                      get_comments_number()
                                                      ) : '';
        $bubble_comment = apply_filters( 'tc_bubble_comment', $bubble_comment );
        $leave_comment_string = __('Leave a comment') . $bubble_comment;
    
        $leave_comment_link = sprintf('<span class="chappie-comments-link comments-link "><a href="%1$s#comments" title="%2$s %3$s">%4$s</a></span>',
                                  get_permalink(),
                                  __( 'Comment(s) on' , 'customizr' ),
                                  get_the_title(),
                                  $leave_comment_string
                                  );
        return $content . $leave_comment_link;
    }

    But you have to style it, you can style the whole span with this selector:
    .chappie-comments-link.comments-link
    and just the bubble (which is the default customizr comment bubble) with:
    .chappie-comments-link.comments-link .fs1 => the bubble
    .chappie-comments-link.comments-link .inner => the number (which needs to be placed better, see top property)

  14. chappie
    Member
    Posted 2 months ago #

    But you have to style it, you can style the whole span with this selector:

    @d4z_c0nf - outstanding! Thank you. Your snippet is superb and imho repairs a little black hole in the platform logic. I will roll it out onto the live site shortly.

    Brilliantly resolved!

  15. d4z_c0nf
    Member
    Posted 2 months ago #

    Tested it?
    Chappie don't thank me, you know we always love you :D

  16. chappie
    Member
    Posted 2 months ago #

    Tested on localhost - just playing with CSS now…

  17. chappie
    Member
    Posted 2 months ago #

    @d4z_c0nf - live testing now and it makes me smile.

    Can't quite figure out why the span top margin grows bigger when a bubble is added but I won't be asking for a refund.

  18. d4z_c0nf
    Member
    Posted 2 months ago #

    What about styling the "Leave comment" span without comments with a bigger top margin, and style the span with comments with a smaller margin?

    You can do this.
    In the code above,

    $bubble_comment = apply_filters( 'tc_bubble_comment', $bubble_comment );
    /* ADD THIS LINE */
     $classes = ( $bubble_comment ) ? 'has_comments' : '';
     $leave_comment_string = __('Leave a comment') . $bubble_comment;

    This way we know if the bubble comment will be added, and we'll add a new class to the span to style it, changing the sprintf this way:

    $leave_comment_link = sprintf('<span class="chappie-comments-link comments-link %5$s"><a href="%1$s#comments" title="%2$s %3$s">%4$s</a></span>',
                                  get_permalink(),
                                  __( 'Comment(s) on' , 'customizr' ),
                                  get_the_title(),
                                  $leave_comment_string,
                                  $classes
                                  );

    What do you think about that?

  19. chappie
    Member
    Posted 2 months ago #

    What do you think about that?

    Well, d4z_c0nf, I think that's very cool and very kind. I'm wondering whether to live with the disparity though since it also serves as an extra visual indicator that there are comments to be read.

    But out of interest, could I have achieved a matched gap between the post text and the comment span if I instead styled the post text with a bottom margin?

  20. d4z_c0nf
    Member
    Posted 2 months ago #

    You cant style the last <p> of the those post types excerpt. But isn't supported by ie<=8
    http://www.w3schools.com/cssref/sel_last-child.asp

  21. chappie
    Member
    Posted 2 months ago #

    Thanks - I'm going to play with p:last-of-type and I'll report back.

    Apologies in advance if I'm slow - I keep getting sidetracked by other things, acts of God, etc…and of course it doesn't help that I really am slow!

  22. d4z_c0nf
    Member
    Posted 2 months ago #

    :) Take your time ;)

  23. chappie
    Member
    Posted 2 months ago #

    Sorry to say, I'm getting nowhere with this. Initially, for simplicity, targeting only the "aside" post format, this is the latest of several ill-judged styling attempts:

    #post .type-post .status-publish .format-aside>p:last-of-type {
    margin-bottom: 20px;
    }

    Be gentle.

  24. d4z_c0nf
    Member
    Posted 2 months ago #

    chappie sorry, I really didn't understand what you want to achieve :D
    Can you explain it a little more to this idiot/feverish guy (me)?

  25. chappie
    Member
    Posted 2 months ago #

    :-) In an attempt to create a common gap between the last para of text and the comment span, I was trying to see whether applying some styling to the last text para would have a more uniform result than applying styling to the comment span - so that the comment span with bubble and comment span without bubble would both display in the same relative position.

    In other words, using one piece of code rather than separately styling the bubble-comment span and the no-bubble comment span.

  26. d4z_c0nf
    Member
    Posted 2 months ago #

    Ok, so I got it. The problem is, you experienced that span with bubble and span without bubble present different positions, this is because of the bubble, of course. Then how can you assign this "fixed" margin to the last p and expecting that will be the same with both, knowing that the "bubble" is the problem?
    In my opinion what you had to do was style the comment span in general with a certain margin top, and decrease that margin for the comment span with the bubble.
    That's why I gave you the possibility to differentiate them with that additional class.

    That's my opinion :), and I can be wrong in general, let alone when I have the fever :D

  27. chappie
    Member
    Posted 2 months ago #

    Okay, okay… But I had it in my head to fix my problem without creating an additional class - and sometimes the head doesn't give up easily (stubborn as a mule).

    How about this: is this a robust fix?

    /*  Short post comment link span+bubble+numeral*/
    .chappie-comments-link.comments-link {
    margin-top: 5px;
    margin-bottom: -20px;
    }
    .chappie-comments-link.comments-link .fs1 {
    display: block;
    line-height: 0.7em;
    position:relative; bottom: 36px; left: 112px;
    color: #8F48E2;
    }
    .chappie-comments-link.comments-link .inner {
    position:relative; bottom: 69px; left: 112px;
    }
  28. d4z_c0nf
    Member
    Posted 2 months ago #

    So you decided to move down the bubble which if that's okay for you, it's okay for me.. but I don't like it esthetically :)

  29. chappie
    Member
    Posted 2 months ago #

    No - I had already moved the bubble down but that didn't help the spacing problem. This was the previous CSS:

    /*  Short post comment link span+bubble+numeral*/
    .chappie-comments-link.comments-link {
    
    margin-top: 0px;
    margin-bottom: -15px;
    }
    
    .chappie-comments-link.comments-link .fs1 {
    position:relative; bottom: -17px;
    color: #8F48E2;
    }
    
    .chappie-comments-link.comments-link .inner {
    position:relative; bottom: -11px;
    }
  30. chappie
    Member
    Posted 2 months ago #

    …and I'm quite happy with it aesthetically (but being a newbie, I'm not blinded by convention). I think that aligning the numeral with the text is more pleasing than shifting it up - but I accept I could be hounded out of the WP community for harbouring such heretical views.

    I would like to test with a big number, eg 258, to make sure it fits, but I'm not prepared to write 257 dummy comments…

Reply »

You must log in to post.

About this Theme

About this Topic