• Resolved spencerpad

    (@spencerpad)


    I made a plugin that schedules a php file to run and update certain posts meta once a day.

    The problem is in the php file that runs once a day, when I load it into my browser gives me this error

    Fatal error: Class ‘WP_Query’ not found in /nfs/c09/h04/mnt/140191/domains/dev.videogamecoupons.com/html/wp-content/plugins/Amazon-price-checker/Example.php on line 6

    $query = new WP_Query( array( ‘cat’ => $pricecat, ‘meta_key’ => ‘ASIN’, ));

    Is the line it is referring to. Do I need to include wordpress functions somehow to make WP_query work in a plugin?

Viewing 1 replies (of 1 total)
  • Thread Starter spencerpad

    (@spencerpad)

    The answer in case anyone searches this was yes, I needed to include wp-blog-header.php which contains the WP_Query class.
    it is found in the root folder of my wordpress installation so I had to relative url it ../../../wp-blog-header.php

Viewing 1 replies (of 1 total)

The topic ‘WP_Query not working in plugin’ is closed to new replies.