Skip to content

Instantly share code, notes, and snippets.

@dbernar1
Forked from asuh/frontend.php
Last active December 11, 2015 00:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dbernar1/4516259 to your computer and use it in GitHub Desktop.
Save dbernar1/4516259 to your computer and use it in GitHub Desktop.
// .content contains content
<div class="content"></div>
<script>
$(document).ready(function() {
// ajax to fetch the slider data.
$.ajax({
type: 'POST',
url: '<?php echo admin_url("admin-ajax.php"); ?>',
data: { action: "front_page_slider" },
success: function(data) {
$('.content').html(data);
}
});
});
</script>
<?php
/**
* Function to call the content
*/
function front_page_slider() {
/**
* The content we want to show
*/
$loadme = '<p>sample sentence</p>';
echo $loadme;
die();
}
add_action('wp_ajax_front_page_slider', 'front_page_slider' );
add_action('wp_ajax_nopriv_front_page_slider', 'front_page_slider');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment