Wordpress - After manually updating mysql table in phpmyadmin for wordpress, the live post reflects the changes, but the post editor does not - mysql

Every year we update our posts with new data. For example, the best places to live in 2018.
I am trying to write a python script this year that updates the post_content in mysql so we don't have to do a bunch of copying and pasting into the html post editor.
However, as a test, I manually updated wp_post in phpmyadmin for one article. After updating, the following happens:
The mysql table correctly updates. I can export the table with the changes and they are all in there.
The LIVE article is updated.
However, when I go to edit the article in wordpress's post editor, it's still showing the previous version.
Therefore, if I save the post in post editor, it will revert back to the old version.
I am completely out of ideas. I've been googling for hours and no one seems to
have this problem.
More background on my setup:
Wordpress version 4.9.1
Using dreampress from dreamhost as the host
Here's a link to the working page:
https://www.homesnacks.net/best-places-to-live-in-georgia-122131/

Ended up hooking into the wordpress API:
https://developer.wordpress.org/rest-api/
And these tutorials helped
https://www.cloudways.com/blog/setup-and-use-oauth-authentication-using-wp-rest-api/
https://discussion.dreamhost.com/t/authenticating-to-the-wordpress-api-using-oauth-1-0a-server/65094

Related

Delete all content from WordPress posts default editor in bulk

I've made a website using ACF and all the content has been copied over from the default WordPress editor, to the new ACF fields.
The trouble is my client didn't delete the content from the default WordPress editor as they went along. Subsequently, it's causing loads of broken links.
Long story short, is there a way to delete all content from the default post editor site wide, rather than update every single post?
To Delete all content from Wordpress posts you will need to export all posts ID in a CSV file.
In PhpMyAdmin you could use
SELECT ID FROM `wp_posts`
Then export the query result in a CSV file. Open the CSV and create a new column for the content which you want empty.
To test my answer, I installed the free version of the 1st WordPress plugin I found for the search query csv import on https://wordpress.org/plugins/
Then on your WordPress dashboard go to this newly installed plugin menu and import the CSV file previously created.
Let the importer update existing posts and define the content as the only column to update.
Before updating All content, I would make a test of the importer configuration on 1 unpublished test post to make sure ACF field aren't emptied with the import.
Which may not happen if you don't miss a configuration on the importer.
In MySQL this is a straight task for deleting all content from the default post, i.e using PHPMyAdmin, SQL section after selecting WP database (i.e find name in wp-config.php):
DELETE * FROM wp_posts
DELETE * FROM wp_postmeta
Please note this will remove definitively ALL content from your website, always take a backup.
You can also find a manual plugin for doing this here.

MySQL Replace Breaks Wordpress Template

I am making a copy of a WordPress website on another server. Everything is OK in copying the database.
However, I need to replace the old domain name "old.com" with "new.com" in some MySQL tables. I am using the following query:
UPDATE wp_options SET option_value = REPLACE(option_value, 'https://old.com/', 'http://new.com/')
This works for a lot of things (like the site URL), however, it breaks all my CSS modifications to the template and all my options, it's sort of restored into default settings directly after I run the previous command.
What could be the reasons?
When moving a Wordpress table the Database Search and Replace Script by interconnect/it does the job very well.
https://interconnectit.com/products/search-and-replace-for-wordpress-databases/
The software is designed for exactly the purpose of replacing olddomain.com with newdomain.com.
All you do is extract Search Replace DB to it's own directory off the root of the Wordpress installation. You then run
newdomain.com/Search-Replace-DB-master
This will automatically find your Wordpress database and will provide search and replace field. It allows a dry run where you can check the results before doing the live run.
Hope this is useful. I have used this many times when changing the domain for a Wordpress installation and it works every time.
Never manually replace URL use https://wordpress.org/plugins/velvet-blues-update-urls/ plugin to safely search & replace old URL with new one.

Moodle - where are URLs/links stored in database?

I'm exporting an old release 1.9.2 and importing to 3.0.2.
Each module has dozens of videos that I play via an URL/link, which points to my own .PHP program on the site (and that wraps a Camtasia video).
I found that in 3.0.2, the link opens on a separate page, unless I edit each link by going to "Appearance", then "Display" and setting it to "Embed".
So I would like to write a mySQL update script to automatically set this flag for all such links (I will add a where clause to my script name).
I checked database in PHP/MyAdmin, and didn't see any likely table names.
You should attempt to use the admin tools to update everything, go to your moodle installation's main URL.
Then go to the site administration. After /admin in the url, add /tool/replace and go there.
You can there enter what you want to find in the db, and replace it with another value. Just be carefull with this tool and make a backup before you begin.

can't create module in bonfire using existing tables

For some reason, I can't seem to create a bonfire module using the "existing" table option.
Earlier, it wasn't even displaying the list of fields from my database table when I selected the option to use existing table vs. creating a new one.
BUt I figured out that it was a permissions thing and so as a test I did the following:
chmod -R 777 /var/www/myapp
Now, it is querying the database and displaying all the correct fields from the table but when I click on the build button, it just keeps redisplaying the same form.
what I've done so far:
I created a test database in my database with just 2 fields. I tried to create a module using that table... but I get the same results.
I've ensured that all my tables are prefixed with "bf_". If they weren't, the system wouldn't be able to find and list all the correct fields... I think.
I've tested creating a new module using a new table. That seems to work just fine. Bonfire creates a new table in my database without any issues and also creates the correct folder structure for the module.
I've tried to ensure that all fields have a proper name validation rules specified.
In most cases, I just accepted defaults and tried to click on build.
changed logging settings to log everything. but after trying to create a module and going back to the logs, there's nothing listed.
If you have any suggestions, I'd appreciate it.
EDIT 1
Figured out how the profiler works - i didn't realize that you had to click on the flame icon on the bottom left corner of the screen.
found the issue. there's a bug with code igniter. found a bug report on their github site.
the post that i found was: https://github.com/ci-bonfire/Bonfire/issues/733

Wordpress migration - MySQL guid column

I have a slight problem with a wordpress migration. I've bulk uploaded posts from csv on my local WAMP server as it's faster and then uploaded & imported a SQL dump to the remote server.
In the guid column of the wp_posts table, it contains the url of the post - I presume (might be wrong, please correct if I am) this is the same as the 'permalink' setting when you edit a post - and all of them are http://localhost/post-name/ which is fine for now, I'm happy to work on an SQL query to replace if needed.
I've uploaded the SQL dump and it still shows 'http://localhost/post-name' in the remote server db as expected. However when I search for a post on the frontend, just to make sure it's picking up the posts OK, I was expecting the links to give me a 404 error until I changed the links, but they don't - they point nicely to the http://remoteserver.com/post-name/
Where as it's a nice problem to have as it still works - I was wondering why & do I need to change it? I prefer to not mess with the db if at all possible.
When migrating, you might need to define your wordpress url in wp-config.php, and I recommend find and replacing the database with this tool. It's pretty neat, because it pre-populates your database from your config file. Obviously, you'd replace http://localhost/ with http://www.yoursite.com/
define('WP_HOME','http://example.com');
define('WP_SITEURL','http://example.com');