Add the following code to dynamically set the base URL for your ACF custom URL field.
Replace slide_url
with the name of your ACF custom URL field
function custom_acf_slide_url_base_url($value, $post_id, $field) {
// Get the base URL dynamically based on the environment
$base_url="";
if (strpos(site_url(), 'staging') !== false) {
$base_url="https://staging.example.com"; // Replace with your staging URL
} else {
$base_url="https://www.example.com"; // Replace with your production URL
}
// Append the relative path to the base URL
$slide_url = $base_url . '/my-page';
return $slide_url;
}
add_filter('acf/load_value/name=slide_url', 'custom_acf_slide_url_base_url', 10, 3);
Related Posts:
- How can i convert my Delphi.NET project to Delphi Prism?
- Moved WordPress to New Server, Now Tries to Download a File
- Migrating Markdown (from Drupal)
- Broken CSS after changing the site URL
- Is it possible just by using wp-cli to migrate one multisite instance to single site?
- Make WordPress “readonly” on a given site
- Is there an easy way to migrate a site from SiteFinity to WordPress?
- Migrate Changes from a Staging Site to Production
- Change old URLs after the domain change
- problem migrating files from https to http mock site – how to see mock site
- URLs to images get messed up after migration
- Migrate localhost to server
- What’s a better workflow for database migration?
- Does WordPress Import/Export tool actually exports media (images) as well?
- Links after moving my site to another domain
- How to just migrate posts/pages from one site to another?
- How do i migrate a Multi site to individual site?
- Migrated site redirects to localhost after successful login
- How do I redirect my blog posts to a subdomain?
- Migration / convert an existing site to WordPress
- Install WordPress on new server or just copy old files?
- Moving a WordPress site from one folder to another (one domain, one server)
- After finishing building a site on localhost, how do I transfer everything to a client’s server?
- how do i find out why links point to my old domain
- How do I force password reset even with wrong password entered?
- WordPress Odd migration issue
- How to copy WordPress live website to Bitnami stack localhost?
- Migrate from CMS Made Simple to WordPress
- Migrating entire online site to local server gives “The requested URL /login/ was not found on this server.”
- Why is the domain name missing from the logout redirect?
- Migrate ProcessWire to WordPress
- Preserve password hashes when migrating to another server
- Automatic Maintenance Mode during All in One Port
- migrating my wordpress site
- Moving WordPress page to a new domain
- Is it possible to transfer my local installation entirely to the server?
- Why WordPress isn’t and/or can’t be domain agnostic
- migrated wordpress site not running properly, on Ubuntu localhost?
- What is the difference between wp-admin>Export>All content and MySql dump and import
- Clean private data (passwords, ftp, database) before zipping my site and SQL and give it to other person
- Mixed Content warnings google fonts
- Import wordpress mysql database to unknown server / domain
- wordpress changing host breaks image links
- Tried to move blogs to a new server – “white screen of death”
- Blank screen after moving WordPress to new server with same domain name
- Moving Some Articles to new site
- I changed my domain name and REST API stopped working
- How to perform User Migration?
- I’m hiding site with index.htm but now I can’t get to index.php
- WordPress migration to new domain and environment with only zip file
- Clone WordPress site from development server to live server
- Server Migration Issues
- Absolute Hyperlinks in WordPress Website Will Not Work In the Local Server
- Migrating WP website from local host
- After migration the website is really slow
- Migration of WooCommerce site
- How to remove symlink from folder
- Migrating from foo.com/wordpress/ to foo.com/ — how can I do it?
- Is there a way to migrate my wordpress blog to another website that uses a different domain?
- How do you do your big exports / imports?
- How do I move a WordPress site on the same server?
- Wrong URL to CSS and JS after change domain
- Migrate site from local to local via a backup
- Migration from environment to master WordPress
- How to recover wordpress website moved from a PC to another
- Making a development site live, on Amazon EC2
- How can I migrate asp.net website to a wordpress site?
- How to duplicate a website?
- How to move my website to wordpress?
- White screen after moving site to new server
- Migrate wordpress server to localhost problems
- Cannot combine two site’s pages together
- Migrating WP site to localhost using Duplicator
- WordPress white screen
- Upgrading a wordpress site to its newest version
- Internal server error
- Redirects and Subdirectory migration to Root Directory
- All styles are looking for the site URL twice
- WordPress migration ended with 500 Error page on pages excluding homepage
- Authorization link broken when migrating from Blogger to WordPress
- How to make Youtube short code transfer
- Migrating WordPress site from subdirectory to subdomain
- Error after moving wordpress blog
- Source code get entity escaped after migrating
- Static HTML to WordPress migration
- Clone wordpress blog on localbox manually
- Moving Site From Development to Production
- Migrated from localhost to server and cannot get custom_fields content anymore
- Can’t restore my wordpress site from zip back up file
- WordPress.com blog migration to self hosted WordPress website [closed]
- Moving Large Number of WordPress posts from One wordpress site to another existing wordpress site
- Site is broken after transferring to adminer
- WordPress migration from live server to localhost having 404 error? [closed]
- Moving wordpress to root folder = internal server error
- Pages do not load after migration to new server
- How to migrate new web design to an existing website?
- open_basedir restriction in effect after migration from LAMP to WIMP
- How to add Featured Image on WXR from External Conversion
- Assets are using old domain name after migrating
- How do I setup my cpanel site backup on a local host?