Adding a column to the posts table is a bad idea, this is indeed what Custom Fields (Post Meta) are for. Query and sort your posts based on the values of your custom field with WP_Query and a post meta (custom field) query:
$query = new WP_Query(
array(
'meta_key' => 'counter',
'meta_value' => 0,
'meta_compare' => '>'
)
);
Related Posts:
- WP_Query – Order results by meta value
- Query to sort a list by meta key first (if it exists), and show remaining posts without meta key ordered by title
- Filter WP_Query for posts having a certain meta-value
- Can I query custom meta data through WP_Query
- Meta Query with AND & OR?
- So much data in postmeta
- What is the advantage of the wp_options design pattern?
- Remove old custom field after import
- How do I search an array stored in a custom-field using WP_Query?
- Edit Custom Database Tables in WordPress
- How do I order by multiple custom fields using wp_query?
- Trying to perform complex custom field query with order by set to field value
- importing data from non-wordpress mysql db
- Query meta field using between
- How to delete custom field “suggestions” from dropdown list
- Order Posts by Closest Numeric Values
- 2 orderby in wp_query with 2 custom fields
- Can serialized arrays in DB be matched against serialized arrays with meta_query?
- How to get a meta value from all post
- Compare meta_query decimals not working right
- Register new user and add custom data row value for it
- Query Problem – Show posts within category ‘x’ that have a custom field between ‘y’ and ‘z’
- After moving my site from a dev subdomain, to root, all my custom meta data is gone
- Front-end update_post_meta with ajax
- Using OR in WP_Query negates the “NOT EXISTS” compare
- WP_query : meta_key with custom rule for specific value
- How can I combine meta_query queries?
- How to filter a dd/mm/yyyy date from a custom field in a query
- Advice needed for importing custom field data and database structure
- Using WP Query to search by multiple meta fields
- Difference between ‘LIKE’ and ‘IN’ in meta queries
- Compare WP Custom Field date
- Sort by posts that have a featured image?
- WP_Query display next custom post from today’s date
- Leader board for game on homepage
- Order by value in serialized custom field
- Which is best in the following scenario : post_meta vs custom table vs parent/child posts
- $wp_query meta_key naming issue [closed]
- Author Page Custom Query WHERE author OR [post meta value] OR [post meta value]
- Meta_query and numeric comparison [closed]
- Default WordPress taxonomy (Tag) – How to add a custom field to form and save it to the database
- Separate table or usermeta
- Custom User Profile Fields
- Adding Custom Fields to Search
- Upcoming Event: How do I sort database by custom date field, but ignore past dates?
- Any way to include custom fields in WP_Query results?
- Get all posts that do not have a specific custom field without using a subquery
- Multiple relationships in a query
- WP Query Returning All Posts
- How do I use wp_query for WordPress search?
- Meta query with timestamp using WP_query
- Conditional custom field query
- Order query by meta_value with multiple custom fields
- Custom fields not getting saved in the databse when added to the add new user profile page
- Auto Populate Custom Field with Complex Value That Increase by One?
- Is there any way to get all meta and standard columns for any WordPress object after searching based on meta key and value
- Is there a better way to list all database terms alphabetically?
- Linking Custom Fields to Database Records
- How to populate custom field dropdown box based on prior selection?
- Custom WP_Query for WordPress Search Results with meta_query
- Meta Query And/Or
- How to combine custom fields to make one order-able value
- When creating a metabox do you have to create DB fields for the data?
- Limit of char count in WP custom fields
- Passing meta_box string to post__in?
- Query post by date (stored custom field meta as yyyymmdd) and differentiate across 12 months
- meta_value and meta_key filtering returning no posts [closed]
- Select custom posts by meta_value and sort by a different meta value
- Can’t query by meta_key
- How to copy data from a custom field to the post_content?
- Diamond question mark in text after migrating content
- Meta query relation ‘OR’ not working as expected
- How do I convert all custom_field php timestamps in the database to js timestamps?
- The best way to collision check in WP
- WP_query multiple custom fields not working
- Custom Query Fields – Altering Meta Value
- How to query for posts with either one or another custom field
- Multiple Custom Field Query
- How to update custom field of a posts in a particular category
- How can I modify my meta_query to work with prices that are stored in the database that contain dollar signs and commas?
- Getting and calculating averge value of custom fields of the same tag
- How To Save Data From Remote APIs To ACF?
- What database state changes happen after a post is manually “updated” with no changes?
- Query to sort a list by meta key first (if it exists), and show remaining posts without meta key ordered by title
- Retrieving and inserting data in custom fields
- I have a form with a custom button ,i want to add the field data to an database when clicking the custom button
- update_user_meta(): invisible data storage
- Populate a select box with data stored in the database?
- Updating custom fields with external data
- WP Query multiple select form – meta_query help
- How to Order Posts by Custom Fields?
- Download stuff after filling fields?
- WP_Query based on multiple metadata comparisons
- Complex WP_Query Using Post Date And Post Meta
- Display posts where date field matches current month?
- Show posts containing or not custom field
- Display agents (custom post type) alphabetically, except one who always shows last
- Website that sells statistics
- Query posts by Custom Meta (checkbox) & Genesis Grid Loop
- How to create a searchable database with a single-field search box at the front end? [closed]