Support » Themes and Templates » Tech Blue Theme – setting post length on front page

  • Resolved Urmas Kungla jr

    (@urmask)


    Hi!

    I can’t send you the link to the blog because it’s under development and front page has been declared accordingly. Still, this is the theme I am working on currently: http://www.themelab.com/2008/02/29/free-release-15-tech-blue/

    The question:
    On front page where I see latest posts I can’t seem to find a place to manually set the limit of post length. Sure I can set it “Limit post length” on options, but it does not seem to work.

    In index.php I have this line:
    <?php the_content('<br />Read rest of the post... &raquo;'); ?>
    but it does not limit the size.

    Where/How can I set the post length manually?

Viewing 2 replies - 1 through 2 (of 2 total)
  • vacmedia

    (@vacmedia)

    function the_content_limit($max_char, $more_link_text = ‘(more…)’, $stripteaser = 0, $more_file = ”) {
    $content = get_the_content($more_link_text, $stripteaser, $more_file);
    $content = apply_filters(‘the_content’, $content);
    $content = str_replace(‘]]>’, ‘]]>’, $content);
    $content = strip_tags($content);

    if (strlen($_GET[‘p’]) > 0) {
    echo “<p>”;
    echo $content;
    echo ” <a rel=’nofollow’ href='”;
    the_permalink();
    echo “‘>”.__(‘Read More’, ‘studiopress’).” →”;
    echo “</p>”;
    }
    else if ((strlen($content)>$max_char) && ($espacio = strpos($content, ” “, $max_char ))) {
    $content = substr($content, 0, $espacio);
    $content = $content;
    echo “<p>”;
    echo $content;
    echo “…”;
    echo ” <a rel=’nofollow’ href='”;
    the_permalink();
    echo “‘>”.$more_link_text.””;
    echo “</p>”;
    }
    else {
    echo “<p>”;
    echo $content;
    echo ” <a rel=’nofollow’ href='”;
    the_permalink();
    echo “‘>”.__(‘Read More’, ‘studiopress’).” →”;
    echo “</p>”;
    }
    }

    Put the above code in functions.php and replace the funnction in index.php with

    <?php the_content_limit(‘200’); ?>

    It works perfectly. Thank you!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Tech Blue Theme – setting post length on front page’ is closed to new replies.