Loading Content section using Ajax (2 posts)

  1. ssdesign
    Posted 8 years ago #

    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(){

    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?

  2. ssdesign
    Posted 8 years ago #

    ok i got it.

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

    to the content which I seperated in another file.

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.