Skip to:
Content
Pages
Categories
Search
Top
Bottom

Truncating Latest Posts


  • KendrickSnyder
    Member

    @kendricksnyder

    Hi, I’m having an issue with my front page. I’m finding that my users might want to post particularly long articles. It wouldn’t be a problem, except that I can’t seem to figure out how to have their front page posts cut off after a certain number of words and display something like “Read More…”

    Has anyone ran into a problem like this? Surely it’s something simple. I’m not sure if it’s an option somewhere in the BuddyPress Dashboard, or if I can download a plugin that can do something like that. I’m not sure where to look

    Thanks for any help.

Viewing 6 replies - 1 through 6 (of 6 total)

  • KendrickSnyder
    Member

    @kendricksnyder

    I went to “Reading Settings” and selected “Summary” for each article feed, but it’s still displaying the full posts… I must be missing something simple.


    KendrickSnyder
    Member

    @kendricksnyder

    Hmm.. I feel like I’m not explaining it right, or maybe I don’t understand something. I found a lot of posts on how to truncate the activity feed, but what they are describing as the activity feed doesn’t sound like what I’m talking about… I’m sure someone has asked this question, so I feel like I’m not asking it right.

    Maybe if someone looked at my page, they would understand what I mean?

    Here’s a link. Under the Featured Articles Lite box, the first post is hundreds of words long.

    http://www.thejoplinvoice.com/

    I know that there is the “Insert More Tag” when you are actually posting an article, but my site will allow anyone that’s a registered member to post articles on the main page. This could cause trouble if I can’t figure out a way to truncate posts after a certain number of words. It’s not a big deal if someone wants to write a novel in a post… but if it displays the full novel on my front page, my website is doomed. I can’t trust that people will be able to figure out what that button does on their own.

    I really feel like I’m not asking the question correctly. Because it seems like this option should be an option in the buddypress menu, I feel like I’m just a noob and I don’t know what I’m looking for.

    Thanks again for any help you can provide.

    Are we talking about posts on your blog (wp-admin) or on the activity stream?


    KendrickSnyder
    Member

    @kendricksnyder

    The Blog Posts (wp-admin)

    The Activity Stream seems to be truncating


    KendrickSnyder
    Member

    @kendricksnyder

    Anyone have any ideas?

    You can definitely limit posts by character count as they’re being inserted. Find where the post form is in your template. I’m using this in Buddypress for the activity stream, so I’m not sure if it’s the same for the regular WP postings. But you should be able to work it around a little bit:

    `

    function limitChars(textarea, limit, infodiv)
    {
    var text = textarea.value;
    var textlength = text.length;
    var info = document.getElementById(infodiv);

    if(textlength > limit)
    {
    info.innerHTML = ‘You cannot write more than ‘+limit+’ characters!’;
    textarea.value = text.substr(0,limit);
    return false;
    }
    else
    {
    info.innerHTML = ‘You have ‘+ (limit – textlength) +’ characters left.’;
    return true;
    }
    }

    Maximum 500 characters.

    `

    You can put that code right before

    `

    Also of note, if you’re doing an AJAX submit that doesn’t refresh the page, you’ll want to have an onclick action set on the submit button that re-inserts the original HTML of the ‘whatsleft’ span back into it. Otherwise they’ll still see the number of characters they had left when they submitted it, even though the form is blank.

    Note: I didn’t write this js, I found it somewhere. Possibly on these forums…but it works :)

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Truncating Latest Posts’ is closed to new replies.
Skip to toolbar