# ============================================================ # MACHU PICCHU ANDEAN # INCA TRAIL FEATURED IMAGES # WPML LANGUAGE: ENGLISH # ============================================================ $user = "Andrea" $appPassword = "TU_APPLICATION_PASSWORD" $site = "https://machupicchu-andean.com" # ============================================================ # AUTH # ============================================================ $pair = "${user}:${appPassword}" $bytes = [System.Text.Encoding]::ASCII.GetBytes( $pair ) $base64 = [Convert]::ToBase64String( $bytes ) $authHeaders = @{ Authorization = "Basic $base64" } # ============================================================ # FIND DESKTOP FOLDER # ============================================================ $possibleFolders = @() $desktop = [Environment]::GetFolderPath( "Desktop" ) if ( $desktop ) { $possibleFolders += ( Join-Path $desktop "inca trail" ) } if ( $env:OneDrive ) { $possibleFolders += ( Join-Path $env:OneDrive "Desktop\inca trail" ) $possibleFolders += ( Join-Path $env:OneDrive "Escritorio\inca trail" ) } if ( $env:OneDriveCommercial ) { $possibleFolders += ( Join-Path $env:OneDriveCommercial "Desktop\inca trail" ) $possibleFolders += ( Join-Path $env:OneDriveCommercial "Escritorio\inca trail" ) } $folder = $null foreach ( $candidate in $possibleFolders ) { if ( Test-Path $candidate ) { $folder = $candidate break } } if ( -not $folder ) { Write-Host "" Write-Host "NO ENCONTRE LA CARPETA" Write-Host "" exit } Write-Host "" Write-Host "==============================================" Write-Host "CARPETA" Write-Host "==============================================" Write-Host "" Write-Host $folder # ============================================================ # IMAGES # ============================================================ $images = @( @{ FileName = "how-to-plan-the-inca-trail.webp" Slug = "how-to-plan-the-inca-trail" Alt = "Hiker planning the Inca Trail to Machu Picchu in Peru" Title = "How to Plan the Inca Trail to Machu Picchu" }, @{ FileName = "inca-trail-altitude.webp" Slug = "inca-trail-altitude" Alt = "Hiker at high altitude on the Classic Inca Trail in Peru" Title = "Inca Trail Altitude" }, @{ FileName = "inca-trail-packing-list.webp" Slug = "inca-trail-packing-list" Alt = "Essential trekking gear for the Inca Trail to Machu Picchu" Title = "Inca Trail Packing List" }, @{ FileName = "best-time-to-hike-the-inca-trail.webp" Slug = "best-time-to-hike-the-inca-trail" Alt = "Hikers on the Inca Trail during clear dry season weather" Title = "Best Time to Hike the Inca Trail" }, @{ FileName = "inca-trail-permits.webp" Slug = "inca-trail-permits" Alt = "Travelers preparing to hike the Classic Inca Trail in Peru" Title = "Inca Trail Permits" } ) # ============================================================ # PROCESS IMAGES # ============================================================ foreach ( $image in $images ) { Write-Host "" Write-Host "==============================================" Write-Host "PROCESSING" Write-Host $image.Title Write-Host "==============================================" $file = Join-Path $folder $image.FileName # ======================================================== # CHECK FILE # ======================================================== if ( -not ( Test-Path $file ) ) { Write-Host "" Write-Host "IMAGE NOT FOUND:" Write-Host $file continue } Write-Host "" Write-Host "Image found:" Write-Host $file # ======================================================== # FIND ENGLISH POST # ======================================================== $slugEncoded = [System.Uri]::EscapeDataString( $image.Slug ) $postUrl = "$site/wp-json/wp/v2/posts?slug=$slugEncoded&status=publish,draft,pending,future,private&context=edit&lang=en" try { Write-Host "" Write-Host "Searching English post..." $posts = Invoke-RestMethod ` -Uri $postUrl ` -Method Get ` -Headers $authHeaders } catch { Write-Host "" Write-Host "ERROR SEARCHING POST:" Write-Host $_.Exception.Message continue } if ( -not $posts -or $posts.Count -eq 0 ) { Write-Host "" Write-Host "ENGLISH POST NOT FOUND:" Write-Host $image.Slug continue } $postId = $posts[0].id Write-Host "" Write-Host "English Post ID:" Write-Host $postId # ======================================================== # READ WEBP # ======================================================== $fileBytes = [System.IO.File]::ReadAllBytes( $file ) # ======================================================== # UPLOAD TO MEDIA # ======================================================== $uploadHeaders = @{ Authorization = "Basic $base64" "Content-Disposition" = "attachment; filename=`"$($image.FileName)`"" } try { Write-Host "" Write-Host "Uploading to Media Library..." $media = Invoke-RestMethod ` -Uri "$site/wp-json/wp/v2/media" ` -Method Post ` -Headers $uploadHeaders ` -ContentType "image/webp" ` -Body $fileBytes } catch { Write-Host "" Write-Host "ERROR UPLOADING IMAGE:" Write-Host $_.Exception.Message if ( $_.ErrorDetails.Message ) { Write-Host "" Write-Host $_.ErrorDetails.Message } continue } $mediaId = $media.id Write-Host "" Write-Host "Media uploaded." Write-Host "Media ID:" Write-Host $mediaId # ======================================================== # ASSIGN WPML LANGUAGE = EN # ======================================================== $languageData = @{ attachment_id = $mediaId language = "en" post_id = $postId } | ConvertTo-Json try { Write-Host "" Write-Host "Assigning WPML language EN..." $languageResult = Invoke-RestMethod ` -Uri "$site/wp-json/chatgpt-content/v2/media-language" ` -Method Post ` -Headers $authHeaders ` -ContentType "application/json; charset=utf-8" ` -Body ( [System.Text.Encoding]::UTF8.GetBytes( $languageData ) ) Write-Host "Requested language:" Write-Host $languageResult.language_requested Write-Host "Detected language:" Write-Host $languageResult.language_detected } catch { Write-Host "" Write-Host "ERROR SETTING MEDIA LANGUAGE:" Write-Host $_.Exception.Message continue } # ======================================================== # ALT + TITLE # ======================================================== $mediaMeta = @{ alt_text = $image.Alt title = $image.Title post = $postId } | ConvertTo-Json ` -Depth 10 try { Write-Host "" Write-Host "Adding English ALT and Title..." Invoke-RestMethod ` -Uri "$site/wp-json/wp/v2/media/$mediaId?lang=en" ` -Method Post ` -Headers $authHeaders ` -ContentType "application/json; charset=utf-8" ` -Body ( [System.Text.Encoding]::UTF8.GetBytes( $mediaMeta ) ) | Out-Null Write-Host "ALT: OK" Write-Host "TITLE: OK" } catch { Write-Host "" Write-Host "WARNING:" Write-Host "Image exists but ALT/title update failed." } # ======================================================== # FEATURED IMAGE FOR ENGLISH POST # ======================================================== $postUpdate = @{ featured_media = $mediaId } | ConvertTo-Json try { Write-Host "" Write-Host "Assigning featured image to English post..." Invoke-RestMethod ` -Uri "$site/wp-json/wp/v2/posts/$postId?lang=en" ` -Method Post ` -Headers $authHeaders ` -ContentType "application/json; charset=utf-8" ` -Body ( [System.Text.Encoding]::UTF8.GetBytes( $postUpdate ) ) | Out-Null Write-Host "" Write-Host "----------------------------------------------" Write-Host "SUCCESS" Write-Host "----------------------------------------------" Write-Host "Post:" Write-Host $image.Title Write-Host "Language:" Write-Host "EN" Write-Host "Post ID:" Write-Host $postId Write-Host "Media ID:" Write-Host $mediaId Write-Host "File:" Write-Host $image.FileName Write-Host "ALT:" Write-Host $image.Alt Write-Host "FEATURED:" Write-Host "YES" } catch { Write-Host "" Write-Host "ERROR ASSIGNING FEATURED:" Write-Host $_.Exception.Message } } Write-Host "" Write-Host "==============================================" Write-Host "FINISHED" Write-Host "==============================================" Inca Trail Weather archivos - Machu Picchu Andean https://machupicchu-andean.com/tag/inca-trail-weather/ Wed, 19 Aug 2026 00:57:34 +0000 es hourly 1 https://wordpress.org/?v=7.0.4 https://machupicchu-andean.com/wp-content/uploads/2026/06/cropped-cropped-Recurso-8@288x-32x32.png Inca Trail Weather archivos - Machu Picchu Andean https://machupicchu-andean.com/tag/inca-trail-weather/ 32 32