Forums

[resolved] Show only one post for day and comments in sidebar (8 posts)

  1. my-web
    Member
    Posted 2 years ago #

    Hello
    I need Show only one post for day and comments in sidebar, withouth widget.
    Can help me?

  2. my-web
    Member
    Posted 2 years ago #

    Escuse, i need show post for certain categories in sidebar with the comments on it, or, for extern news I will have the opportunity to add comments in the news.
    It's possible?

  3. my-web
    Member
    Posted 2 years ago #

    Hello how i can show one post for selected category in sidebar??

  4. MichaelH
    Volunteer
    Posted 2 years ago #

    One example (doesn't address your comments):

    <?php
    //get 5 recent posts in categories 3 or 19.  Useful for sidebar or php code widget
        $args=array(
          'showposts'=>5,
          'category__in' => array(3,19),
          '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(); ?>
            <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
           <?php
           the_content();
          endwhile;
        } //if ($my_query)
      wp_reset_query();  // Restore global post data stomped by the_post().
    ?>
  5. my-web
    Member
    Posted 2 years ago #

    Thanks it work good, but i need show limitated number of characters and if possible add comment number or "Add reply", how i can do it?

  6. MichaelH
    Volunteer
    Posted 2 years ago #

    1. Replace the_content(); with echo 'this is 40 chars of content >' . substr($post->post_content,0,40);
    2. Template_Tags/comments_popup_link

  7. my-web
    Member
    Posted 2 years ago #

    Thanks a lot!!!

  8. whitehats
    Member
    Posted 2 years ago #

    This is awesome, thanks!!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags