0

What I want to do is I want to display the popular post as a page. I have created a template page to display the popular post. But it is not working as I want it to. The thing that I want it to do 1. Display the 1st set of popular post, may be one set contain 10 post. 2. After sometime another set of popular post is displayed but the 1st set of popular post must be down at the button of the 2nd set of popular post. 3. The posts of 1st sets of popular post should not be displayed in 2nd set of popular post.

Till now i have written the following code.

<?php
/*
Template Name: Hotpage
*/
?>

<?php get_header(); ?>
<div id="content">

      <div class="filterbar_scnd">
    <h1>
            <a href="#">
        <?php if ( is_day() ) : /* if the daily archive is loaded */ ?>
            <?php printf( __( 'Daily Archives: <span>%s</span>' ), get_the_date() ); ?>
        <?php elseif ( is_month() ) : /* if the montly archive is loaded */ ?>
            <?php printf( __( 'Monthly Archives: <span>%s</span>' ), get_the_date('F Y') ); ?>
        <?php elseif ( is_year() ) : /* if the yearly archive is loaded */ ?>
            <?php printf( __( 'Yearly Archives: <span>%s</span>' ), get_the_date('Y') ); ?>
        <?php else : /* if anything else is loaded, ex. if the tags or categories template is missing this page will load */ ?>
            NGAG is your best source of fun.
        <?php endif; ?>
            </a>
    </h1>
      </div>
      <div id="content_inner">
      <?php query_posts('orderby=comment_count&order=DESC&paged=' . get_query_var('paged'));?>

           <?php if (have_posts()) : while (have_posts()) : the_post(); ?>

                 <ul class="lp_lists">
                    <li class="lp_container">
                        <div class="lp_left">
                            <?php if(has_post_thumbnail()) :?>
                            <div class="thumbnailimg">
                                    <?php the_post_thumbnail(); ?>
                            </div>
                            <?php endif; ?>
                            <div class="lp_desc">
                             <?php the_excerpt(); ?>
                            </div>
                        </div><!--lp left ends-->
                        <div class="lp_right">
                            <div class="lp_title">
                               <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
                            </div>
                            <div class="lp_category">
                                <?php the_category(', ') ?>
                            </div>
                            <div class="lp_dates">
                               <?php echo get_the_date(); ?><span class="spacer">at</span><?php echo get_the_time(); ?>
                            </div>
                            <div class="lp_comments">
                                <div class="lpc_butt">

                                </div>
                                <div class="lpc_words">
                                   <div class="lpc_counter"><?php comments_number( 'No comments', 'One comment', '% comments' ); ?></div>
                                </div>
                            </div>
                            <div class="lpc_sharing">
                                <div class="lpcs_top">
                                </div>
                                <div class="lpcs_bottom">

                                        <div class="lpcs_sbutt">
                                            <a href="https://twitter.com/share" class="twitter-share-button" data-url="<?php the_permalink() ?>" data-text="<?php the_title(); ?>" data-count="horizontal"></a>
                                        </div>
                                        <div class="lpcs_sbutt" id="lpcs_fbutt" >
                                            <iframe src="//www.facebook.com/plugins/like.php?href=<?php the_permalink() ?>&amp;send=false&amp;layout=button_count&amp;width=85&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font=arial&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:85px; height:21px;" allowTransparency="true"></iframe>
                                        </div>

                                </div>
                            </div>
                        </div><!--lp right ends-->
                        <div style="clear: both;"></div>
                    </li><!--lp container ends-->
                    </ul>

    <?php endwhile; else: ?>
        <div class="no-results">
            <p><strong><?php _e('There has been an error.'); ?></strong></p>
            <p><?php _e('We apologize for any inconvenience, please hit back on your browser or use the search form below.'); ?></p>
            <?php get_search_form(); /* outputs the default Wordpress search form */ ?>
        </div><!--noResults-->
    <?php endif; ?>
    </div>

    <div class="oldernewer">
        <p class="older"><?php next_posts_link('&laquo; Older Entries') ?></p>
        <p class="newer"><?php previous_posts_link('Newer Entries &raquo;') ?></p>
    </div><!--.oldernewer-->

</div><!--#content-->
<?php get_sidebar(); ?>
<?php get_footer(); ?>

I am not able to do any of the thing I want to do. Any help is really appreciated.

look here

<?php query_posts('orderby=comment_count&order=DESC&paged=' . get_query_var('paged'));?>

           <?php if (have_posts()) : while (have_posts()) : the_post(); ?>

Right Now It just displays the top popular post. I want to change this in a way so that I can show the popular post as I want in above points.

  • 1
    What isn't working as expected, or is happening unexpectedly, with this code? – Chip Bennett Nov 24 '13 at 14:30
  • It is really not clear what you are trying to accomplish. – s_ha_dum Nov 24 '13 at 16:33
  • I have edited the question. you can see the last part of questions. – diwas bhattarai Nov 24 '13 at 18:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.