• Resolved preskoo

    (@preskoo)


    Hello. I am developing a custom WordPress theme and I wondered if there’s a way to limit the post length when displaying it on the index page? I have read all about the_content() and the_excerpt(), but none of them seem to work. The code I am using in my page.php template is:

    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    
     <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
    
       <?php the_content(); ?>
    
     <?php endwhile; else: ?>
    
     <?php endif; ?>

    And to get the content from my pages and display it in a custom css box on my index page, I use this code:

    <?php
    $page_id = 78;
    $page_data = get_page( $page_id ); 
    
    echo apply_filters('the_content', $page_data->post_content);
    ?>

    The problem is that the whole content of the page is displayed in this box, and I want to reduce it. I have tried using the ‘More’ option in the WYSIWYG editor, but still no result. Does anyone have any suggestions on how to fix this? Thank you

Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Post length’ is closed to new replies.