WordPress.org

Ready to get started?Download WordPress

Forums

Problem on loading a new template file using jQuery. Call to undefined function (2 posts)

  1. Nikolas
    Member
    Posted 3 years ago #

    Hello, I am trying to reload the fresh posts using jQuery. As far as I know, I can't reload the contents of a div inside the page so I reload a file into that div. (Is that correct?)

    The problem is that my loaded file gives me a **Fatal error: Call to undefined function wp_query()**

    How can I implement functions to a newly created file inside the theme directory to work properly?

    ***This is my jQuery***

    <script language="JavaScript">
        $(function() {
            var SANAjax = function(){
                $('#reservationdetails').empty().addClass('loading')
                  .load('wp-content/themes/theme/reloadhomeposts.php', function() {
                     $(this).removeClass('loading')
                  });
            }
            setInterval(SANAjax, 15000 );
        });
        </script>
        <div id="reservationdetails"></div>

    ***And this is what i have in reloadhomeposts.php (I have deleted the content though)***

    <?php $recent = new WP_Query("cat=3,4,5&showposts=10"); while($recent->have_posts()) : $recent->the_post();?>
        .
        .
        .
        <?php endwhile; ?>
  2. esmi
    Forum Moderator
    Posted 3 years ago #

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags