Support » Themes and Templates » Loading Content section using Ajax

  • Hi All,

    I am trying to do some Ajax implementation in my wordpress theme.

    Here is what I would like to do:

    1. Remove the content loading part from the Index.php
    2. Copy that part in a new file called mainpage.php and place it in the themes foloder.
    3. Add Ajax script in the header and create a function to load the URL like this at the top of header:

    <script src=”prototype.js”></script>
    var myGlobalHandlers = {
    onCreate: function(){‘systemWorking’);

    onComplete: function() {
    if(Ajax.activeRequestCount == 0){


    function xajax_slows_function(arg)
    var url = arg;
    var myAjax = new Ajax.Updater( ‘AJAXID’, url, { method: ‘get’});


    Now to load the main.php I add this script just at the end of the header php:

    xajax_slows_function(‘<?php bloginfo(‘stylesheet_directory’)?>/mainpage.php’);

    When I run it, I get this error:
    Fatal error: Call to undefined function query_posts() in C:\Program Files\xampp….\mainpage.php on line 5

    Can the content part from the Index.php not be seperated like I am trying to do?

Viewing 1 replies (of 1 total)
  • ok i got it.

    I had to add:
    <?php require(‘../../../wp-blog-header.php’); ?>

    to the content which I seperated in another file.

Viewing 1 replies (of 1 total)
  • The topic ‘Loading Content section using Ajax’ is closed to new replies.