I am working on a project where I need to be able to change the template being used if a given shortcode is used. To complicate things more, the plugin must also be able to rewrite
$query if this same shortcode is called.
I believe that I am running into issues in when various parts of the core exec vs. when shortcodes run, but I can't find the right information in the Codex to verify or debug the issue. Currently, my implementation neither modifies
$query nor does it redirect the template.
Basically, the shortcode works (or, in this case, does not work) as follows:
- Shortcode is called
- Based on what info is in shortcode, args are generated to retrive some posts
- These args are assigned to a global variable, let's call it
$custom, within the shortcode function
- Also within the shortcode, I hook
get_home_template()as the argument
- Also in shortcode function,
pre_get_postsis hooked with a function that assigns
new new WP_Query( $custom )
Like I said, I'm quite sure it's an order of exec issue, but I'm not sure where to look in order to figure out what needs to be modified. Any suggestions would be greatly appreciated!