WordPress.org

Forums

how to limit the size of the post on frontpage (9 posts)

  1. wishmaster22
    Member
    Posted 6 years ago #

    I am looking for a place in the admin section to adjust how long each post on the frontpage is. Is there a setting to limit the length and add a more more tag?

    thanks

  2. Shane G
    Member
    Posted 6 years ago #

    Hi,

    Please use this function to set the max number of post on home page..

    From ALl Categories:

    <?php
    $page_num = $paged;
    if ($pagenum='') $pagenum =1;
    query_posts('showposts=7&paged='.$page_num); ?>
                   	<?php if (have_posts()) : ?>
    		<?php while (have_posts()) : the_post(); ?>
                    endwhile;endif;
    ?>

    From Specific Categories:

    <?php
    $page_num = $paged;
    if ($pagenum='') $pagenum =1;
    query_posts('cat=1&showposts=7&paged='.$page_num); ?>
                   	<?php if (have_posts()) : ?>
    		<?php while (have_posts()) : the_post(); ?>
                    // WordPress loop
                    endwhile;endif;
    ?>

    use this code in index.php file of your there...

    Thanks,

    Shane G.

  3. wishmaster22
    Member
    Posted 6 years ago #

    Thanks for that code, but I need to limit the size of the post, such as 350 characters and have a read more for the rest of it.

    can this be done?

  4. Saurus
    Member
    Posted 6 years ago #

    click the "more" tab in the html editor where you want to break the post. Using the "excerpt" tag in your php breaks a post at 55 characters. I know of no way to set it to break at another number autotmatically.

  5. Natrepub
    Member
    Posted 6 years ago #

    Is there a way to do this without the "More" button? I have Contributors on my site and I would like to be able to automatically limit the size of the post on the home page.

    Thanks!

  6. wishmaster22
    Member
    Posted 6 years ago #

    There has to be a setting for this.

    Somebody please help us.

    Thanks

  7. aptdesignonline
    Member
    Posted 5 years ago #

    Hey guys,

    Here is a plugin that automatically limits the post lengths on the homepage:

    http://wordpress.org/extend/plugins/wp-limit-posts-automatically/

    Hope that helps.

  8. mathechr
    Member
    Posted 5 years ago #

    Maybe try using <?php the_excerpt(); ?> instead of <?php the_content(); ?> on the main page?

    If you don't enter text in the excerpt area, it will just use a chunk of the beginning of the post with a [...] at the end.

    Not sure if there's a way to configure the number of characters this uses, though.

  9. renato_s
    Member
    Posted 5 years ago #

    From the Codex:
    Control Excerpt Length using Filters

    By default, excerpt length is set to 55 words. To change excerpt length using excerpt_length filter, add the following code to functions.php file in your theme:

    function new_excerpt_length($length) {
    	return 20;
    }
    add_filter('excerpt_length', 'new_excerpt_length');

    http://codex.wordpress.org/Template_Tags/the_excerpt#Control_Excerpt_Length_using_Filters

Topic Closed

This topic has been closed to new replies.

About this Topic