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
- How to use multiple query with same meta key
- How to create a custom config file and get data using inline JS in a wordpress page
- Add product tag names to WooCommerce new order email subject
- Check if current page is wp-admin
- WordPress custom image size on custom field image
- List User order by ID in Descending order (Backend)
- hook that when page is starting to load
- Ajax category filtering products default show all
- How to exclude category ID from Looper in WordPress
- Custom user login page by creating a plugin
- Why ajax doesn’t work on certain wordpress hooks?
- Whitelisting items from custom options page
- Add_menu_page not displaying the menu in class based plugin
- multiple taxonomy select display only one in front end
- How to store options in an array
- Generate sidebar depending on height of post
- Get author and excerpt from URL
- Error using WordPress $wpdb object to get result from custom table
- Sidebar not appearing in footer, but it appears everywhere else!
- How to create table in wordpress without plugin? [closed]
- How do you create two separate Register pages?
- In WordPress, how do I get the number of posts next to single_cat_title(”); in the category.php file?
- Include only posts with meta key “add_in_rss” in RSS Feed
- get db values for external js file
- How to exclude a widget from W3 Total Cache Plugin
- How to split AJAX response into two divs
- Deleting expired session tokens in WordPress
- Creating a brand attribute as a variable
- Illegal string offset in PHP function in via Theme Customizer
- How to hide the file name of 404.php in URL?
- when hooking to pre_user_query my wordpress crashes when using very simple commands?
- I am having errors with checkout on wordpress
- Display articles with a different template in the home page | Solved |
- How to use Multi SQL Database in WordPress?
- Help me understand how Search function works using dynamic_sidebar()
- How to display post meta bellow every posts
- Sudden Upload HTTP errors, PHP uploads and memory limits are already to high to my taste. Anything else?
- Thumbnail wouldn’t scale to size properly
- PHP script to redirect traffic based on website accessed
- How to remove title tag with this filter
- How to handle the structure of page/taxonomy/post without making wordpress get confused with the url
- Add two or multiple functions in WordPress Post or Page
- special characters not supporting in wordpress
- Custom user roles doesn’t apply changes
- A Space being added to url generated by custom plugin
- Why this plugin is not working?
- get_post_meta is always empty when I use wp_mail
- How to execute add_action() function from custom plugin to Crontrol plugin or do_action()?
- rest_cannot_create_user – Sorry, you are not allowed to create new users. CURL WORDPRESS REST API
- links Slick jS library using wp_enqueue_scripts not pulling
- How to change shipping method title based on cart amount?