• Hi,

    is there a possibility to get the length of every individual post? It′s necessary for a modification of my theme.

    Greetz

    dg

Viewing 1 replies (of 1 total)
  • You mean like:

    <?php
    $args=array(
      'post_type' => 'post',
      'post_status' => 'publish',
      'posts_per_page' => -1,
      'caller_get_posts'=> 1
    );
    $my_query = null;
    $my_query = new WP_Query($args);
    if( $my_query->have_posts() ) {
      while ($my_query->have_posts()) : $my_query->the_post(); ?>
        <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
        <?php
      echo 'length of post content is '. strlen( $my_query->post->post_content);
      endwhile;
    }
    wp_reset_query();  // Restore global post data stomped by the_post().
    ?>

    Related:
    https://php.net/manual/en/function.strlen.php

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