Wordpress Excert Question

Discussion in 'WordPress' started by AzharNadeem, Nov 5, 2012.

  1. #1
    AzharNadeem, Nov 5, 2012 IP
  2. ashishkg

    ashishkg Active Member

    Messages:
    233
    Likes Received:
    8
    Best Answers:
    3
    Trophy Points:
    68
    #2
    You will use this
    function the_content_word($max_char, $more_link_text = '(more...)', $stripteaser = 0, $more_file = '') {
    $content = get_the_content($more_link_text, $stripteaser, $more_file);
    $content = apply_filters('the_excerpt', $content);
    $content = str_replace(']]>', ']]>', $content);
    $content = strip_tags($content);

    if (strlen($_GET['post']) > 0) {
    echo $content;
    }
    else if ((strlen($content)>$max_char) && ($espacio = strpos($content, " ", $max_char ))) {
    $content = substr($content, 0, $espacio);
    $content = $content;
    echo $content;
    echo ".";
    }
    else {
    echo $content;
    }
    }

    And call <?php echo the_content_word('100');?> instead of <?php the_excerpt(); ?>

    It will help you or you will contact me via Skype/Gtalk: ashishkg17
     
    ashishkg, Nov 5, 2012 IP
  3. RSchaefer

    RSchaefer Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    [From the WP Codex]

    function custom_excerpt_length( $length ) {
        return 20; // where '20' is whatever number of words you want
    }
    add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );
    PHP:
    Place these three lines in your theme's functions.php file.
     
    RSchaefer, Nov 5, 2012 IP