Creating and Using Tables in the WordPress Database

The requirements you’ve specified don’t indicate any need for a custom post table. Just register a custom post type using register_post_type(), and then manipulate its entries using the standard WordPress API. Example from the codex, registering a ‘book’ custom post type with a label of “Books”: function my_init() { $args = array( ‘public’ => true, … Read more

Database migration issues – Error #1046 No database selected

99.99% chance that you configure wordpress with wrong database details. make sure you are using correct database details in wp-config.php file /** The name of the database for WordPress */ define(‘DB_NAME’, ‘database_name_here’); /** MySQL database username */ define(‘DB_USER’, ‘username_here’); /** MySQL database password */ define(‘DB_PASSWORD’, ‘password_here’); /** MySQL hostname */ define(‘DB_HOST’, ‘localhost’); some possibilities are … Read more

WordPress $wpdb no result

Your specific issue in that code is that you’re missing the quote marks around the $code. $query .= ‘WHERE code=”.$code; Should be: $query .= “WHERE code= “‘.$code.'”‘; In the long run, you should indeed use prepare() properly, but this is the specific problem with the code you posted.

How to delete ALL comments from certain category in WordPress database?

The wordpress database seems fairly straight forward and is extremely well documented: http://codex.wordpress.org/Database_Description It seems to me that all the category information is stored in the table wp_term_relationships. So you should select from the comments table, join it with the posts table and then the term_relationships table in order to get the category for each … Read more

Way to extract wordpress data from folder backup

There’s two elements to this: Restoring the mySQL database which hopefully resided in your wamp folder. This will be where the actual post data is in. See Restoring MySQL database from physical files Restore MySQL database folder from a recovered Hard Disk   Restoring the files themselves. The most straightforward way to do this will … Read more

querying user bookmarks from a large number of bookmarks

It looks like the default get_bookmarks() http://codex.wordpress.org/Function_Reference/get_bookmarks is using this query: SELECT * FROM wp_links WHERE 1=1 AND link_visible=”Y” ORDER BY link_name ASC; You can check the function in /wp-includes/bookmark.php. The get_bookmarks() function has limit and order parameters that you might find helpful. The option get_bookmarks(“limit=5”) gives this query: SELECT * FROM wp_links WHERE 1=1 … Read more

Select From wpdb – Author/User Directory page

You’re probably better off to use get_users which returns an array of <?php // get all users, regardless of roll. If you do need to restrict by // role you can use the `role` argument: get_users(array(‘role’ => ‘author’)); $uses = get_users(array(‘orderby’ => ‘nicename’)); foreach ($users as $user) { // do stuff with $user, will have … Read more

Fixing YARPP plugin FULLTEXT MySQL indexing

YARPP doesn’t do anything on uninstall. So you have to uninstall it then go remove the indexes manually from the DB. The index names should be prefixed with yarpp_. Very untested SQL follows: SHOW INDEXES ON wp_posts; DROP INDEX yarpp_title ON wp_posts; DROP INDEX yarpp_content ON wp_posts;