Create Table Failed Column Date DateType

Well, after looking at the other tables I had created successfully, only difference was the description column. Apparently WordPress or MySQL doesn’t like that as a column name and somehow has it reserved. So, after renaming it, the table was created fine. Hope this helps someone else in the same boat.

How does offset works on pagination? (get_results)

The problem here is the LIMIT, it’ll just count the first page and not the entire query. I had solved it by providing a secondary SQL query for counting the max pages. thanks for my friends for this tip. here’s the complete code. function.php function spiciest(){ global $wpdb, $paged, $max_num_pages; $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) … Read more

SQL Query to select post title & post ID from a particular category

You can use $args = array( ‘post_type’ => ‘post’ ,’posts_per_page’ => 10, ‘category_name’ => ‘orange’ ); $query = new WP_Query( $args ); printf( ‘<h2>Generated SQL:</h2><pre>%s</pre>’, $query->request ); to display the generated SQL query. The above example will give you: <h2>Generated SQL:</h2> <pre> SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts INNER JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) WHERE … Read more

Retriving array size from serialized data

Your Query is wrong beacuse your are searching for the user_id inside the meta_value column instead of the user_id column. In this case i see no point in creating a custom query just for that, So here is how you can do it using the native function get_user_meta $data = get_user_meta( get_current_user_id(), ‘bookmark_posts’ ); $number … Read more