Copy post to separate database with “add_action(….)”
Copy post to separate database with “add_action(….)”
Copy post to separate database with “add_action(….)”
You can use the switch_to_blog() function to temporarily use data from a specific site instead of the current site. switch_to_blog(1); // Switch to Site ID 1 // wp_nav_menu(); restore_current_blog(); // Switch back to Current Site // restore_current_blog switches back to the current blog’s data.
You should wirte a Function or Plugin inside WordPress to achive that. First, you could insert the tables into your WordPress Database. After that, make sure you make good use of the WordPress postsstructure. Set up a Loop through your existing Posts that you want to import. At each Post create a WordPress Post using … Read more
After a lot of searching and asking people who are far more clued up than myself, I have concluded that this is impossible mainly because it requires two concurrent DB connections. In the end, my SSO solution was to build a more traditional SSO system that creates users in the remote site using the user … Read more
a simple and Not perfect solution which will do most of the job for you is to overwrite the table names like this: function custom_prefix_change($sql) { global $wpdb,$wp; $prefix = $wpdb->prefix; if(is_single()){ //check if the post exists in the genuine posts table $results = $wpdb->get_results($sql,”ARRAY_A”); if($results[0][‘ID’]){ //if exists then return return $sql; }else{ //else change … Read more
I found out what is wrong. The tutorial says to remove all double quotes ” and replace them with spaces or backticks `, but some values in the mentioned tables have double quotes around them. This one for example: INSERT INTO “wp_usermeta” VALUES(14,1,’wp_capabilities’,’a:1:{s:13:”administrator”;s:1:”1″;}’); So replacing that with backticks causes malfunction. Replace only double quotes around … Read more
if ( !$value ) evaluates to TRUE when the value is 0. Alternative: if ( ! isset ( $_POST[‘_ordre’] ) ) return delete_post_meta( $post_id, ‘_ordre’ ); update_post_meta( $post_id, ‘_ordre’, $_POST[‘_ordre’] ); You don’t need add_post_meta(), the call to update_post_meta() will do that automatically.
Multisite 404 on pages – rewrite error breaks database
For anyone else running into a similar issue with Azure Cloud hosting and ClearDB … read below (even though this is very specific to my site and db config): Fixed the issue. This was a database specific issue with Azure and ClearDB and not pointing to the correct database. I was using a free version … Read more
For style and code reference about the default WordPress interface elements, I use the plugin WordPress Admin Style, by Frank Bültge. It shows CSS ID’s and classes, and screenshots, for the following elements: Full plugin page screenshot at GitHub.