Seems like you already have the custom field for views set up since that’s a phpMyAdmin screenshot. If so, you can use order_by="post_views_count"
in most wp_query
based calls. For instance:
$args = array(
'post_type' => 'your_post_type',
'orderby' => 'meta_value_num',
'meta_key' => 'post_views_count',
);
$query = new WP_Query( $args );
//...and on with the loop
<?php while ( have_posts() ) : the_post(); ?>...
Limiting this behavior to category 3 is pretty easy but how go about it depends on the context and your template setup.
More on orderby
in the WP Codex
Related Posts:
- WooCommerce – Customer Order History Pagination
- Would manually deleting the dumping data fix a “#1062 – Duplicate entry ‘1’ for key ‘PRIMARY'” phpMyAdmin error?
- Get a Page’s attachments in Gallery order
- How can I set custom order use this function
- List of posts by day of the week
- #1062 – Duplicate entry ‘1’ for key ‘PRIMARY’
- WooCommerce: Add Payment Gateway Field to Webhooks [closed]
- Limiting woocommerce line_total decimal length
- get_terms orderby numeric
- phpMyAdmin displays error when importing database
- Automatically remove a canceled order in Woocommerce
- Sort query_posts for Parent Pages to menue order or the count?
- How to display data from custom table in wordpress phpmyadmin
- Remove the first 5 characters of the_title and orderby that
- Is it possible to create a wordpress database with php code?
- how to fix error “called incorrectly, should not be accessed directly”?
- Set Order Status to Complete After Payment – from another site
- comments sorting incorrectly across multiple pages
- Trouble Installing WordPress Get PHP Not Running Answer
- Update a buggy installation
- get_total () returns 0 – woocommerce [closed]
- Display all pages – in order
- how to get serialized post meta
- Live to Local on MAMP, not working, outputting functions.php code
- Order BY Most Liked And Published Between Previous Week Monday And Next Week Monday
- WordPress redirects to old login after migration
- phpMyAdmin error #1062 – Duplicate entry ‘1’ for key ‘PRIMARY’
- Plugin can’t write to database even though permissions appear correct?
- How to track who has deleted files
- How to WP_Query posts order by parent title?
- Error establishing a database connection (Set-up locally)
- Updating user meta adds string count to value?
- How can I change the background color of divs dynamically (depending on an order-status in woocommerce)?
- Unable to insert two value in two different columns (WordPress database)
- why not selecting multiple rows of same standard_id using SQL query from database?
- Can I disable auto increment of WordPress Posts Database to utilize previously deleted records?
- WordPress PHP version
- How to override WooCommerce Order Item Meta with data from Cart?
- How to sort (orderby) a query done by a template function before the ‘foreach’ loop?
- 403 Forbidden Localhost Wamp Apache Php
- Changing WordPress author name in database
- How to merge 2 WordPress sites?
- Query category-specific, paginated posts and allow viewer to change sort order
- reorder a WP_Query, using a dropdown
- How to run site locally after downloading database
- How can I display all these movies in DESC order by modified?
- using custom pages for myaccount in woocommerce
- How to use phpspreadsheet reader with $wpdb
- Importing data from excel sheet on webpage rather than from within phpMyAdmin
- Using WooCommerce Hooks to add product attribute descriptions to customer order email
- 404 Error after URL update
- How to return count number from a wordpress database
- Exclude specific post from displaying
- Update postmeta after theme switch
- Update post title from external file?
- Parse error: syntax error, unexpected end of file
- Troll the hackers by redirecting them
- PHP in CSS file?
- How would I use this filter to change the output of the date format to “Twitter time”?
- WP Business Directory Manager Plugin Admin Listings?
- Putting php inside an echo php shortcode
- Add login hyperlink to secondary navigation menu
- WordPress import media error
- Warning: Illegal string offset on theme options page [closed]
- How do I get an external php page to load using javascript
- Help getting previously visited pages ID
- How do I create a numbered list with PHP? [closed]
- Why in my theme I can’t see all the statics content under the posts?
- Woocommerce display one random product via php
- What does $_GET[‘iphone’] do?
- Change url tag name
- Backend of the WordPress.com [closed]
- Conditional using get_the_ID() not working [closed]
- Appended comments but they show up above the content instead of below
- get_template_directory adding FTP root folders in urls
- Custom ajax call returns 0 [duplicate]
- How to solve Woocommerce Memory Limit
- Metabox Not saving data
- 2nd page displaying the exact same posts as my first page (minus the very first post)
- Hide image if taxonomy term is empty
- Fatal error: Call to undefined function register_new_user()
- Shortcode to find and replace URL
- Remove the More Link
- Why is my str_replace not working on short code submitted by front-end?
- Detecting if parent page has gallery
- Skip foreach loop
- Displaying posts based on category
- stripping tags from excerpt in WordPress is not working
- Prev/Next Links Broken on Static Front Page Pagination
- Pagination broken on is_front_page()
- Changing the color scheme based on the url visited
- Why is an array created in a function hooked to customize register populated when customizer is loaded but not when the front-end is loaded?
- Mixing variables into an array when inserting values
- Don’t show certain div on front page?
- Could use some help with Shortcodes
- How to integrate noimage picture in this code
- Javascript not loading on certain page
- Location of core code for database connection and get_header
- Deleting Certain terms from appearing on the front end as links
- get comment data using comment id