Update text from mysql database

On a page I have a text item that I want to be able to update to be the value from a separate MySQL database. So the page will go and get the value from the database and the content for the text. This will allow me to make bulk changes to multiple text fields direct in my database externally to X theme.

Hi There,

Backup your website and test it. If your pages are still editable once you do that, you are good.

Cornerstone uses serialized data and can be sensitive to this type of approach.

You could try this plugin : https://xthemetips.com/global-blocks-for-cornerstone/591/

Hope it helps

I found another way to do this and post as it might be helpful to others…

Create a text item and enter the code:

[insert_php]
global $wpdb;
$result = $wpdb->get_row ( "SELECT my_column_name FROM my_table where product_id = ‘shoe’ " );
echo $result->my_column_name ;
[/insert_php]

In the WP database I have a new table ‘my_table’ with a column ‘my_column_name’
So this sql will return the value from the table where product_id = “shoe” and use this returned text from the database as the actual text for the value.

This solution needs the insert_PHP plugin

Thanks for sharing your solution.

Cheers!