astroo
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: Form Not added in WebsiteThanks you @wpmajestic. It works
Forum: Installing WordPress
In reply to: Military drone Website Image Upload Issues in WordPress@fierevere I check PHP memory limit. It is okay. No issue in that.
Can you check on this page:- This reply was modified 2 months, 1 week ago by Yui.
- This reply was modified 2 months, 1 week ago by James Huff. Reason: link moved to proper field in OP
Forum: Installing WordPress
In reply to: Where is the ALT data of images located?Hi Daniel,
The location of your old image data depends on your setup. If you’re using a content management system like WordPress, the images are usually stored in the
/wp-content/uploads/
folder on your old domain’s server. You can export them via FTP or your hosting control panel.If you’re manually managing your site, check the directory where your images were uploaded. After retrieving the files, you can upload them to your new domain.
Forum: Developing with WordPress
In reply to: Remote database data manipulationFrom your description and code, it seems you want to transfer user data from a local WordPress database to a remote database. Your approach is almost correct, but there are a few issues that could be causing the blank page or preventing the code from working. Key Points to Check and Suggestions:
- Check for PHP Errors:
Blank pages often indicate a PHP error. Even though you have enabled debugging, PHP errors might not be outputted correctly. You can add the following code at the top of your file to ensure all errors are displayed:
ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL);
- Syntax Error in Your Code:
There is a mistake in this line:
$external_users = $other_db->'users';
It should be:
$external_users = $other_db->prefix . 'users'; // Assuming 'users' table has a prefix
or simply:
$external_users = 'users';
The
->
operator cannot be used to directly access a string. You need to correct that.- Inserting Data into the Remote Database:
Thewpdb::insert()
method should be called on the correct$other_db
instance, not the local$wpdb
instance. Your code should look like this:
$other_db->insert( $external_users, array( 'username' => $user->user_login, 'hash' => $user->user_pass, 'email' => $user->user_email, ) );
- Database Table Structure:
Ensure that the remote database has the exact table structure for theusers
table and that the column names match. For example, if the column names areuser_login
,user_pass
, anduser_email
, use those exact names. - Debugging:
You can add logging to see if your code runs up to a certain point. For example:
error_log('Reached this point before inserting data.');
Check the
debug.log
file in thewp-content
directory for the logged messages.- Database Connection Validation:
You’re currently checking the connection like this:
if (!$other_db) { echo $wpdb->show_errors(); }
However,
$other_db
is an object, so this check will always pass. Instead, validate the connection using thelast_error
property:if ( $other_db->last_error ) { error_log('Database connection error: ' . $other_db->last_error); } else { echo 'Connected successfully'; }
- Avoid Hardcoding the Table Name:
WordPress tables usually have prefixes (likewp_
). Use the$wpdb->prefix
property to handle this dynamically if needed.
Final Revised Code Example:
require __DIR__ . '/wp-load.php'; define( 'WP_DEBUG', true ); define( 'WP_DEBUG_LOG', true ); ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); global $wpdb; $other_db = new wpdb($other_db_user, $other_db_password, $other_db_name, $other_db_host); if ( $other_db->last_error ) { error_log('Database connection error: ' . $other_db->last_error); } else { echo 'Connected successfully'; } $user = get_userdata($user_id); if ( $user ) { $external_users = 'users'; // Adjust the table name as needed $result = $other_db->insert( $external_users, array( 'username' => $user->user_login, 'hash' => $user->user_pass, 'email' => $user->user_email, ) ); if ( $result === false ) { error_log('Insert error: ' . $other_db->last_error); } else { echo 'Data inserted successfully.'; } } else { error_log('User not found.'); }
Additional Tips:
- Make sure the remote database user has the correct permissions to insert data.
- Ensure that the remote table structure and column names match the data you’re inserting.
- Check the
debug.log
file and PHP error output for clues if the issue persists.
This should resolve your issues and help in successfully inserting data into the remote database.
Forum: Everything else WordPress
In reply to: product images on appearing twice on mobile viewPossible Solution for Product Images Duplicating on Mobile Devices
It sounds like the issue might be related to the WooCommerce hover effect or a theme-related conflict. Here’s a step-by-step approach to troubleshoot and hopefully resolve the issue:
- Disable WooCommerce Image Hover Effects:
- Add the following CSS code to your theme’s
Additional CSS
section in the Customizer:
.single-product div.product .woocommerce-product-gallery .flex-control-nav, .single-product div.product .woocommerce-product-gallery__trigger { display: none !important; } .single-product div.product .woocommerce-product-gallery .woocommerce-product-gallery__wrapper { pointer-events: none; }
This code disables the hover effect and may prevent the images from duplicating. - Add the following CSS code to your theme’s
- Check for Theme or Plugin Conflicts:
- Temporarily switch to a default WordPress theme like Twenty Twenty-One to see if the issue persists. If the problem disappears, it’s likely a theme conflict.
- Deactivate all plugins except WooCommerce and see if the problem is resolved. If it is, reactivate each plugin one by one to identify the culprit.
- Clear Mobile Cache:
- Clear the cache on your mobile browser to ensure that you’re not seeing a cached version of your site with the issue.
- Test Different Devices/Browsers:
- Test your site on different mobile devices and browsers to see if the issue is consistent across all platforms.
- Responsive Image Settings:
- Ensure that your theme is correctly handling responsive images. Some themes have settings specifically for mobile images, so double-check those.
If these steps don’t resolve the issue, it might be helpful to share more details like the theme you’re using or any customizations you’ve applied, as that can help others provide more targeted advice.