Certainly! Here’s how you can backup your files with a _yyyymmdd suffix and then update the originals using SSH commands.
Let’s assume today’s date is 2024-06-13 (adjust as needed).
1. Set a Date Variable
DATE=$(date +%Y%m%d)
This will set $DATE to 20240613.
2. Backup the Files
Navigate to your theme directory (adjust path as needed):
cd /path/to/your/wordpress/wp-content/themes/photography/templates/
Now, for each file, copy it with the date suffix:
cp template-topmenu.php template-topmenu.php_$DATE
cp template-topmenu-left.php template-topmenu-left.php_$DATE
cp template-fullmenu.php template-fullmenu.php_$DATE
cp template-sidemenu.php template-sidemenu.php_$DATE
Or, all at once:
for f in template-topmenu.php template-topmenu-left.php template-fullmenu.php template-sidemenu.php; do
cp "$f" "${f}_$DATE"
done
3. Edit the Original Files
You can use nano, vim, or your preferred editor. For example, with nano:
nano template-topmenu.php
nano template-topmenu-left.php
nano template-fullmenu.php
nano template-sidemenu.php
In each file:
- Find
height="16" and change it to height="48" (or your desired value).
- Save and exit the editor.
4. (Optional) Use sed to Update All Files Automatically
If you want to automatically replace all height="16" with height="48" in these files, you can use:
sed -i 's/height="16"/height="48"/g' template-topmenu.php template-topmenu-left.php template-fullmenu.php template-sidemenu.php
Summary of Commands
# Set date variable
DATE=$(date +%Y%m%d)
# Go to the theme templates directory
cd /path/to/your/wordpress/wp-content/themes/photography/templates/
# Backup files
for f in template-topmenu.php template-topmenu-left.php template-fullmenu.php template-sidemenu.php; do
cp "$f" "${f}_$DATE"
done
# Edit files manually
nano template-topmenu.php
# (repeat for each file)
# OR: Update all files automatically
sed -i 's/height="16"/height="48"/g' template-topmenu.php template-topmenu-left.php template-fullmenu.php template-sidemenu.php
Always check your site after making changes!
If you need to restore a backup, just copy the backup file over the original:
cp template-topmenu.php_$DATE template-topmenu.php
Let me know if you need further help!