WordPress.org

Ready to get started?Download WordPress

Forums

Loading Content section using Ajax (2 posts)

  1. ssdesign
    Member
    Posted 7 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>
    <script>
    var myGlobalHandlers = {
    onCreate: function(){
    Element.show('systemWorking');
    },

    onComplete: function() {
    if(Ajax.activeRequestCount == 0){
    Element.hide('systemWorking');
    }
    }
    };

    Ajax.Responders.register(myGlobalHandlers);

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

    }
    </script>

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

    <script>
    xajax_slows_function('<?php bloginfo('stylesheet_directory')?>/mainpage.php');
    </script>

    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
    Member
    Posted 7 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

Tags

No tags yet.