How to return number of found rows from SELECT query

If you are merely trying to get a count, $wpdb->get_var(); along with using COUNT() in your sql will be better: ### Search for IP in database function postviews_get_ip($id, $ip) { global $post, $wpdb; $rowcount = $wpdb->get_var(“SELECT COUNT(*) FROM $wpdb->wp_postviews_ips WHERE postid = $id AND ip = ‘$ip'”); return $rowcount; } postviews_get_ip($id, $_SERVER[‘REMOTE_ADDR’]); //both $id and … Read more

How do I show data from gravity forms in my template? [closed]

You can look at the docs, but you’ll probably end up reading the real documentation: the source code. If you do, you’ll find that: GFFormsModel::get_leads($form_id) returns a list of entries for a form (maybe you know that one already), where each item in the array is itself an array, an “Entry object“ GFFormsModel::get_form_meta($form_id) returns a … Read more

where is permalink info stored in database?

In the wp_options table there is a record where option_name = “permalink_structure”. However, the true, ultimate control of url rewriting is controlled by the WP_Rewrite API which saves/caches its information in the rewrite_rules wordpress option (also found in the wp_options table). EDIT: Also, when editing a page/post, you can change the “permalink” for that page/post … Read more

How To Find Out WordPress Category Table in MYSQL?

See the Codex’s WordPress Taxonomy documentation. WordPress 2.3 replaced the previous categories, post2cat, and link2cat tables with three a more flexible set of taxonomy tables. wp_terms wp_term_relationships wp_term_taxonomy wp_terms– holds the basic information about single terms. term_id bigint(20) unsigned NOT NULL auto_increment, name varchar(200) NOT NULL default ”, slug varchar(200) NOT NULL default ”, term_group … Read more

WPDB Insert or if exists Update

First, you are using prepare incorrectly. You seem to have $wpdb->update‘s arguments wrapped in $wpdb->prepare like that. That won’t work. In effect, you are passing update a single argument– the output of prepare. Try something simple like the following and you will see why that won’t work: $post_id = 123; $item_stock = 567; var_dump( $wpdb->prepare( … Read more

When is the ‘post_content_filtered’ column in database cleared by WordPress?

Every post update in WordPress is handled by the wp_update_post function. This function has some defaults, and for post_content_filtered the default value is ” (empty string). Once the defaults are merged with args passed to function via wp_parse_args it means that every time a post is updated and post_content_filtered is not explicitly passed, it is … Read more