Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9014369
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:29:26+00:00 2026-06-16T03:29:26+00:00

How can I display my most viewed posts on a single page ? For

  • 0

How can I display my most viewed posts on a single page ?

For this moment, i’ve create a new template page (content-most-viewed.php) wich is called by get_template_part();

On Internet, i’ve read that query_posts could solve my problem, but it seems to fail.

This is my template :

<?php query_posts('meta_key=post_views_count&orderby=meta_value_num&order=DESC');
//query_posts('post_type=post&posts_per_page=10&orderby=comment_count&order=DESC');?>
<div class="post">
    <?php if (have_posts()) : ?>
        <?php while (have_posts()) : the_post(); ?>
            <div class="heading">
                <h2><a href="<?php the_permalink(); ?>"><?php the_title();?></a></h2>
            </div>
            <?php the_content();?>
            <div class="link-holder"><a href="/index.php">Retour</a></div>
        <?php endwhile; ?>
    <?php else : ?>
        <div class="heading">
            <h2>Not Found</h2>
        </div>
        <p>Sorry, but you are looking for something that isn't here.</p>
    <?php endif; ?>
</div>

But, I can only get recent posts, or “Not Found” (any resutls)

In advance, thanks !

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T03:29:27+00:00Added an answer on June 16, 2026 at 3:29 am

    WordPress by itself does not keep track of the number a post is viewed there are pluging that do this: WPP, plugin repos
    These plugins will have build in functions to do this.

    side note
    don’t use query_posts its bad for preformance. use WP_query in stead. reasons why it is bad: https://wordpress.stackexchange.com/a/50762/10911, https://wordpress.stackexchange.com/a/50762/10911

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using PHP to display the most recent tweet from a user. This is
I can display a simple Visual Basic inputbox from a PowerShell script like this:
In Visual Studio you can display the Call hierarchy of a single function. What
Is there any firefox addon which can display my asp.net page viewstate size.... Any
I want to develop JSF page which can display the swap size if the
I have this code which can display drop down in div tag of html.
I'm building a responsive image gallery page which can be viewed here . Using
I'm using Facebook recommendations on my blog( http://techdreams.org ) to display most liked/shared content.
I used php on my website so it can display multiple languages. I noticed
I'm struggling with this. I've got it to display most of the list, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.