Articles of table

Moving to another host; which tables to move in a database

I’m moving my website to a new host and would like to move only my posts and images to the new site. I don’t want to use WP export because I’ve had bad experiences going that route. I don’t want to copy the entire database, just copy the posts and images in the database. What […]

Creating table with plugin is not working

After reading many question and answers and many had asked the same question I have been following the same instruction as the people instructed but my bad it’s not working I have used dbDelta($sql) $wpdb->query($sql) It’s not working sample code <?php /* Plugin Name: ContactUs Plugin URI: Description: Simple Plugin Developed for Testing purpose Version: […]

What table is the media's sort order stored?

I see that your can sort media by a numbered order in the media gallery for a post. But what table is this order stored in? I want to use this order to also order the images the same way in my posts.

Table for plugin-list-category-post?

I’m using the list-category-post plugin – is it possible to display the list of posts in a table? I want to have a dynamic table showing all the posts in a category, so a user can search the table and select a column to sort by. Is this possible? Thanks,

Return number of items in a table with post id

I am trying to return the number of reviews for a given page ID, I have this so far: <?php global $wpdb; $countreviews = $wpdb->get_var($wpdb->prepare(“SELECT COUNT(ID) FROM $wpdb->wpcreviews WHERE page_id = ID”)); echo ‘Number Of Reviews ‘ . $countreviews . ”; ?> Its not working and I assume it’s the end part page_id = ID […]

Creating search form for custom database table

I have a custom table in the WP database which I can display fine, with pagination, using the following code: <?php global $wpdb; $rows_per_page = 50; $current = (intval(get_query_var(‘paged’))) ? intval(get_query_var(‘paged’)) : 1; $rows = $wpdb->get_results( “SELECT * FROM nc_rates_eng”); global $wp_rewrite; $pagination_args = array( ‘base’ => @add_query_arg(‘paged’,’%#%’), ‘format’ => ”, ‘total’ => ceil(sizeof($rows)/$rows_per_page), ‘current’ […]

How to implement WP_List_Table? WP_List_Table giving array instead of a value in listing table

I am trying to implement WP_List_Table for my plugin. I have gone through this tutorial and using its sample plugin. I have installed this plugin and just changed table name and done slightly modification in the following functions: column_name,get_columns and get_sortable_columns Now it is showing the table but instead of value it is showing array […]

Can't pass table to $wpdb->prepare

I’m having trouble passing a table variable to $wpdb->prepare(); Here is functioning code: $table = $wpdb->get_blog_prefix( $blog_id ) . ‘my_table’; $voters = $wpdb->get_row($wpdb->prepare(“SELECT * FROM $table WHERE user_id= %d AND post_id = %d;”, $user_ID, $post->ID )); This works great. However I think I should also be including my table in the prepare statement. But, it […]

Why majority of fileds in wp_posts table prefixed with post_?

Why for example field in wp_posts table is called “post_title” instead of “title”? Is this somehow related to b2cafelog legacy code for backward capability? Or is there other explanation for this? This question applies to other core WordPress tables too.

The plugin generated x characters of unexpected output, $wpdb not defined

I’ve written a simple WordPress plugin to create a new database table. The new table ought to be created when the plugin is activated. When I try to activate the plugin, I get the following error: The plugin generated 3989 characters of unexpected output during activation. If you notice “headers already sent” messages, problems with […]