Output custom content not from the posts table?

Basically you want custom posts in WordPress that will be just pointers to external data? If you don’t want full import then: Store some kind of unique property identifier (that makes sense for your external data) as meta field or guid in custom post type. Make wrapper function that will take ID of your custom … Read more

Insert post in another database

You could avoid SQL altogether and use the XML-RPC API. This would also let you post to remote wordpress installs too. ( note if XML-RPC is not an option, scroll further down ) If Using XML-RPC Here’s some code from a quick google search using XML-RPC to post to a remote WordPress blog: http://en.forums.wordpress.com/topic/great-code-for-remote-posting?replies=5 Here’s … Read more

Switching database on the fly

Yes it works! This is the code, assuming both the databases share the same username & password: $wpdb->select(‘mydbname’); wp_cache_flush(); Once done, re-issue the same statements, with the original database name. Can’t see any performance issue at the moment, maybe because this is done when building a custom form picking data from two posts out of … Read more

MySQL Rank & $wpdb

You might try: SELECT NULL AS rank, player, points FROM my_table Then write a tiny loop to fill in the value for rank in each returned record?!?!? It’s a workaround rather than a solution but in the end, you’ll have what you need.

Using GROUP CONCAT in my-sql query with wp_usermeta table

How about a Pivot Query? This would return rows that have first_name,last_name,user_login. You could then add whatever condition you wanted using a WHERE clause. SELECT MAX(CASE WHEN wp_usermeta.meta_key = ‘first_name’ then wp_usermeta.meta_value ELSE NULL END) as first_name, MAX(CASE WHEN wp_usermeta.meta_key = ‘last_name’ then wp_usermeta.meta_value ELSE NULL END) as last_name, wp_users.user_login FROM wp_users LEFT JOIN wp_usermeta … Read more

How to split the a table in database?

Sharding is probably not what you want, especially if the admin area is the only problem. If things are working fine on the front end, you’re probably okay. How many posts are we talking about total? Some things worth trying (please back up your DB first!): 1. Remove all old post revisions A quick count … Read more