wordpress change home url code example
Example 1: wordpress ajax url
<?php
add_action( 'wp_footer', 'my_ajax_without_file' );
function my_ajax_without_file() { ?>
<script type="text/javascript" >
jQuery(document).ready(function($) {
ajaxurl = '<?php echo admin_url( 'admin-ajax.php' ) ?>';
var data = {
'action': 'frontend_action_without_file',
'variable_name': "Some value"
};
jQuery.ajax({
url: ajaxurl,
type: 'POST',
data: data,
success: function (response) {
console.log(response);
}
});
});
</script>
<?php
}
add_action("wp_ajax_frontend_action_without_file" , "frontend_action_without_file");
add_action("wp_ajax_nopriv_frontend_action_without_file" , "frontend_action_without_file");
function frontend_action_without_file(){
echo json_encode($_POST);
wp_die();
}
?>
Example 2: change site url wordpress database
options table
1. siteurl
2. home
######## OR ########
define( 'WP_HOME', 'http://example.com' );
define( 'WP_SITEURL', 'http://example.com' );