Should be:
$where .= " AND voted > 1";
Other notes:
-
instead of hardcoding table names you should use
$wpdb->prefix . 'post_votes'
; -
instead of checking in global
$_GET
you should declare your filters as accepting two arguments and code functions accordingly, these filters pass as second argument object that contains all of query data.
Like:
add_filter('posts_where', 'vote_where', 10, 2 );
function vote_where( $where, $query ) {
if( isset( $query->query_vars['vp_sort'] ) );
$where .= ' AND voted > 1';
return $where;
}
Related Posts:
- Delete post revisions on post publish
- How to sort results from a custom database table
- WP database error for comments_popup_link()
- Create WP_Query to search for posts by their categories or their parent/child categories
- How can I display a query in a page?
- Check if values exists DB
- Check if post of title already exists
- $wpdb->delete column values IN ARRAY()?
- How To Make Connection To WordPress Data Base In A Plugin?
- Changing user_nicename
- Does WordPress cache get_user_meta() results?
- WordPress will not operate correctly
- How to Join two tables from separate databases within WordPress
- error importing localhost export file to server
- Would manually deleting the dumping data fix a “#1062 – Duplicate entry ‘1’ for key ‘PRIMARY'” phpMyAdmin error?
- How to track a users progress through pages by inserting data into WordPress Database?
- Import 10,000 Users into WordPress WITH a specific ID for each user
- if statement on database query
- Is the regular ajax request method safe or I should use admin-ajax.php?
- Unusable menus and “Illegal widget setting ID: nav_menu_item[]” error
- my function doesn’t return my post from today
- No wp-config.php file on local install of wordpress – site still displays
- How to migrate the posts from an old custom legacy blog to a new WordPress website?
- Is it good practice to use wpdb->query() function?
- Insert all post IDs in new database table
- Different database query in function.php using mysqli
- How to create and work with custom data / tables (i.e., for arbitrary data)?
- Prevent Data Resubmission On Page refresh
- Why is variable not working on custom sql query using wpdb?
- Any possible way to make $wpdb->get_results() return anything else than array?
- Accessing the database from a plugin outside of action hooks
- Trying to establish connection to External Database
- How to insert a single row to WP database table?
- WSoD being caused by this piece of code
- mysql query from wordpress page using custom table
- only show container with next/prev links if they exist?
- ACF: how do I get the fields and its values of a specific group?
- How to check if a meta value has already been assigned to any user?
- How can I save unique user data on my site? [closed]
- Update results, Before deleting the related category [closed]
- Long running queries
- database sent to a JSON file
- inserting a post from an extern php file but post content doesn’t show on wp site
- Using $wpdb (WPDB class) ‘replace’ with multiple WHERE criteria problem
- $wpdb->wp_users returning empty value for
- Using custom tables for old posts
- register_taxonomy() take much queries
- WordPress SQL injection
- Not connecting to database in file with multiple MySQL connections
- Display Data in Table from External Database in WP using Shortcodes
- WordPress Block developer from exporting Database via PHP
- wpdb prepare insert table doesn’t work
- Should I use WordPress to skin a database website?
- How do I display offsite database info on my wordpress site?
- WordPress and MySQL: trying to print data using PHP from user_meta custom field data
- Issue with fetching mysql data and displaying results via shortcode in webpage
- I can’t update my data through $wpdb
- How to use mysql LIKE with wpdb?
- How to add data to a custom field at the wp_users table?
- Why when I create a new post I found 2 record related to this post into the posts database table?
- Adding data to custom wordpress database table
- mySQL queries are executed twice on wordpress website
- phpMyAdmin error #1062 – Duplicate entry ‘1’ for key ‘PRIMARY’
- Add row to custom database Table and delete all rows older than 1 day
- select a single val though a table in wordpress
- making php value numeric
- WordPress Custom Query: Combining Two Functions
- Modify WooCommerce used to get all orders in dashboard
- What’s wrong in my PHP code? I’m using WordPress Astra Theme and I can’t insert data into my SQL
- Database entry removed on browser refresh, Ajax PHP jQuery
- Please help! I have a problem with getting wordpress databas
- Error establishing a database connection (Set-up locally)
- Create a new account on site B with data from the purchase of site A
- PHP Warning: mysqli_query(): after updating my websites php from 5.6 to 7.2
- Using wpdb to connect to a different database is not working
- How can i limit the number of posts to the most recent 6 in my query?
- Insert data from form to database
- Query doesn’t display text data with apostrophes
- How to query a staging database?
- How to do a MySql query in WordPress?
- Include a custom field in mysql query
- How to set max users to 17.000
- How to set up an auto delete post?
- Weird Behaviour: Not all WordPress Posts appearing
- two wordpress sites, two themes, one database, same content
- Insert double entry in DB
- Unserializeing multiple column values that are stored in one database results variable
- How to connect database table to each registered wordpress user.
- Let users register weight each day and save it in DB
- MySQL database migration to WordPress
- Custom query_posts() parameter
- How to pass username into form that sends data to database
- How to edit the default database of WordPress [closed]
- Query Concatenation
- Display total count of products in orders of a specific order status
- Execute multiple PHP Snippets causes error?
- Custom form that stores data in mysql database
- Exclude a category ID from the following function
- Putting form result in my database
- Can’t insert into a database wordpress