If instead of modifying functions.php you can modify wp-config.php, you can use the following:
define('WP_HOME','http://example.com');
define('WP_SITEURL','http://example.com');
Source: https://codex.wordpress.org/Changing_The_Site_URL#Edit_wp-config.php
Related Posts:
- Database & Post Search
- Displaying posts on a page that have been assigned a value in a database
- Unable to get WordPress’s apply_filters(‘site_url’) to return a https scheme
- Add Default WordPress Formatting To Data From External SQL Tables?
- Insert HTML just after tag
- the_content and is_main_query
- How to Pass External Variables to Filters/Actions
- Filter by one custom field, order by another?
- How to pass/get data to/from the WooCommerce data-product_variations object?
- Filter username field on registration for profanity and unwanted words
- At what priority does add_filter overwrite core functions?
- Add whitespace between Chinese and other letters
- How to add icons to post listing (edit.php) in admin
- Tiny MCE editor stripping xlink:href parameter from SVG USE tag
- Add quick edit fields without custom colum
- Prevent 404 when using pre_get_posts to filter an archive page
- Hook added to the_content seems to be called multiple times
- Translating an error message
- Keep Users Logged In As Long As I Like
- Is it possible to remove the filter from 4.8 text widget?
- Display WooCommerce newest product reviews on top [closed]
- Overriding wp_get_archives() apply_filters()
- How to make post and comment count unclickable with dashboard_glance_items hook
- Call to undefined function error after adding add_filter to wp-config
- How to remove X-Frame-Options: SAMEORIGIN” from WordPress?
- How can I hide all posts that don’t have a thumbnail?
- Add Dropdown menu using “add_filter => wp_nav_menu_items”
- Filtering ‘the_title’ with option to return subhead?
- Restrict filter to run only inside specific function
- How to add a custom filter in functions.php
- Setting title using wp_title filter
- 4.0 remove_filter for WordPress core function not working for me
- How do I add a current class to the current post?
- How apply_filters work in WordPress?
- Apply a filter only once
- What functions are included in apply_filter(‘the_content’)
- Filtering admin entries for custom post type
- What hook/filter can I use to add/edit/show/hide the title under (on hover) links on the table view?
- option_active_plugins filter not working
- How do we check if the user is logging in or registering?
- What is the purpose of storing `siteurl` in database?
- Anonymous function is executed twice in wp_head while added from the_posts filter?
- add_filter return value
- Add a header before fields added with the attachment_fields_to_edit() filter
- Are there Limitations on filter handles?
- Hide content editor for posts after approriate date
- Why my admin doesn’t work after adding rest_prepare_post filter?
- Buddypress: Edit activity when new blog post [closed]
- How to make a button?
- Filter or Hook to catch pre-rendering of post content
- Sorting and limitation with pre_get_posts
- Warning: Missing argument 2 for widget_title filter
- check to see if hook is available
- Use add_filter on concatenated string variable
- Change term name only on front
- Filter users by custom colum not meta key
- How do I hide the current page’s title?
- How to allow users to view pending posts of a specific custom post type?
- Remove filter callback: method in class
- Change name of existing post status type
- add_filter(‘the_content’, ‘…’) stops pagination from working
- How can I exclude tags from category_rss function?
- How to filter meta_values using REST API
- Header image automatically changes depending on season
- How to remove SKU’s from ALL products in Quick View – already remove from each product page
- How do I use remove_action on an add_action that uses an array?
- Admin Backend – Search Pages only by title
- How to hide Ads in between posts on AMP? [closed]
- What is the downside of using a filter as a “poor man’s” dependency injection?
- Change the default 10-day expiration for the password protected pages cookie
- Add content as soon starts
- Access get_the_title() from ‘excerpt_length’ filter
- Wrong post_status notice after wp_insert_post_data
- BBPress changing default group activity
- How can I change the language of automated Mails?
- Comment search plugin
- Why doesn’t remove_action work in my plugin?
- Using a filter to modify Genesis wp_nav_menu
- What is the earliest hook to modify post content?
- How to modify only part of a function through the filter
- Something is filtering my shortcodes… Can’t figure out what
- Remove actions/filters that are set with create_function()
- Hook in a sidebar widget and add some markup
- return get_the_tag_list with whitespace removed
- ‘manage_users_custom_column’ is a filter, but ‘manage_posts_custom_column’ is an action. Why?
- Modify author url display in edit-comments.php
- Filter Post Title without affecting screen-reader-text
- Hook to change the site URL
- Strange behaviour of REGEX in a WordPress filter (trying to suppress emtpy paragraphs)
- Widget image reorganize layout
- WordPress set featured image to first image of the post
- Modify category listing API response
- Auto-generated excerpt with shortcode and read more button/text link
- Converting restricted html in comments to bbcode
- What is the proper/best way to have multiple add_filter for wp-job-manager-resume
- How to replace all images in all posts and pages with a different size?
- How to add a class to Buddypress avatars in the Activity stream? [closed]
- using posts_where for meta data on pre_get_posts
- How properly write function to filter content in a template for plugin “multiple content blocks”
- ACF Load Field Groups Programmatically [closed]