Query behaves differently depending on where it runs from
-
I’m developing a plugin for a newsletter site.
On the home page of this site is a display of all the Dates and Deadlines, News Articles, and Announcements custom post types that are current.Inside the plugin is a feature to grab all those current Dates and Deadlines, News Articles, and Announcements and compile them into a viewable preview showing what it would look like inside a specific Pardot email template.
You’d think the biggest challenge here is negotiating Pardot’s API from within the plugin, but it’s not.
The function the populates the front page is just a PHP template inside a custom theme in the site.
The function that populates the Pardot preview is a similar function that runs from within the custom plugin I’m developing.
The two queries return different results for some reason. Not different sets of articles, but the Pardot preview… it just shows one article (it’s correct, it should be shown, but there should be others as well)
I even went so far as to take the entire page template from the theme and put the code into a shortcode in the plugin, but same result.
I’m a little puzzled by this as in the case of my plugin shortcode vs. the theme template page code, it’s EXACTLY same code and query, running from two different places in the site (theme and a plugin) with different results.
I can and am currently putting together a sample of the pages in question on the dev site and will provide links shortly.
- The topic ‘Query behaves differently depending on where it runs from’ is closed to new replies.