View: Limit Post plugin

  1. 1 year ago by kaosklub
    1. <?php
    2. /*
    3. Plugin Name: Limit Posts
    4. Plugin URI: http://labitacora.net/comunBlog/limit-post.phps
    5. Description: Limits the displayed text length on the index page entries and generates a link to a page to read the full content if its bigger than the selected maximum length.
    6. Usage: the_content_limit($max_charaters, $more_link)
    7. Version: 1.1
    8. Author: Alfonso Sánchez-Paus Díaz y Julián Simón de Castro
    9. Author URI: http://labitacora.net/
    10. License: GPL
    11. Download URL: http://labitacora.net/comunBlog/limit-post.phps
    12. Make:
    13.     In file index.php
    14.     replace the_content()
    15.     with the_content_limit(1000, "more")
    16. */
    17.  
    18. function the_content_limit($max_char, $more_link_text = '(more...)', $stripteaser = 0, $more_file = '') {
    19.     $content = get_the_content($more_link_text, $stripteaser, $more_file);
    20.     $content = apply_filters('the_content', $content);
    21.     $content = str_replace(']]>', ']]&gt;', $content);
    22.     $content = strip_tags($content);
    23.  
    24.    if (strlen($_GET['p']) > 0) {
    25.       echo "";
    26.       echo $content;
    27.       echo "";
    28.    }
    29.    else if ((strlen($content)>$max_char) && ($espacio = strpos($content, " ", $max_char ))) {
    30.         $content = substr($content, 0, $espacio);
    31.         $content = $content;
    32.         echo "";
    33.         echo $content;
    34.         echo "...";
    35.         echo "";
    36.    }
    37.    else {
    38.       echo "";
    39.       echo $content;
    40.       echo "";
    41.    }
    42. }
    43.  
    44. ?>
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/1579"></script>

0 comment about "Limit Post plugin"