• hi all,

    I’m trying to create a list of all posts with date-title(post)-xlines of chars.

    I wrote this code… but, its giving some messed(last but first post doesn’t show its date/ as a list) results.

    Code is as follows: `

    • <?php
      $args=array(
      ‘showposts’=>0,
      ‘caller_get_posts’=>1
      );
      $my_query = new WP_Query($args);
      if( $my_query->have_posts() ) {
      /* echo ‘5 recent Posts’;*/
      while ($my_query->have_posts()) : $my_query->the_post(); ?>
    • <?php the_time(‘m.d.y’) ?>    ” rel=”bookmark” title=”Permanent Link to <?php the_title_attribute(); ?>”><?php the_title(); ?>
            <?php
      echo substr($my_query->post->post_content,0,120); //20 chars of content
      endwhile;
      } //if ($my_query)
      wp_reset_query(); // Restore global post data stomped by the_post().
      ?>
    • `

Viewing 2 replies - 1 through 2 (of 2 total)
  • something gone wrong with the code posting – despite your backticks.

    there are no list tags visible in your code (ul, li), and not much html tags, so could you try to re-post the code in a readable way?

    Thread Starter desibird

    (@desibird)

    sure…

    backticks
    <?php
    /**
    * @package WordPress
    * @subpackage Default_Theme
    */
    ?>
    <div id=”sidebar” role=”complementary”>

      <?php /* Widgetized sidebar, if you have the plugin installed. */
      if ( !function_exists(‘dynamic_sidebar’) || !dynamic_sidebar() ) : ?>

    • <?php
      $args=array(
      ‘showposts’=>0,
      ‘caller_get_posts’=>1
      );
      $my_query = new WP_Query($args);
      if( $my_query->have_posts() ) {

      while ($my_query->have_posts()) : $my_query->the_post(); ?>

    • <?php the_time(‘m.d.y’) ?>    ” rel=”bookmark” title=”Permanent Link to <?php the_title_attribute(); ?>”><?php the_title(); ?>
            <?php
      echo substr($my_query->post->post_content,0,120); //20 chars of content
      endwhile;
      } //if ($my_query)
      wp_reset_query(); // Restore global post data stomped by the_post().
      ?>
    • <?php endif; ?>

    </div>
    backticks

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

The topic ‘Display posts titles as lists’ is closed to new replies.