Add filter for get_posts params for automatic content blocks
-
We are having a specific situation with an extremely easy fix that I would propose. Basically, we use the Event Organiser plugin which has a couple custom query args when running get_posts/WP_Query.
It would be helpful to all future developers that would like to plug in with their custom post types with Mailpoet to include a filter in lib/Newsletter/AutomatedLatestContent.php. Right now you do have filters unsuppressed, which is great, although there is no specific way to target this call to get_posts specifically using pre_get_posts.
What you should do is use a filter for the args like so (approx line 71 before the call to get_posts):
$parameters = apply_filters( "mailpoet_alc_{$parameters['post_type']}", $parameters, $this->newsletter_id );
This would allow people to filter the custom query to their needs by doing something like this:
add_filter( 'mailpoet_alc_event', function( $parameters, $newsletter_id ) { if ( $newsletter_id === 1 ) { $parameters['group_events_by'] = 'series'; } return $parameters; });
If you accept pull requests I submit one myself but would be a really simple and helpful fix to many I would venture.
- The topic ‘Add filter for get_posts params for automatic content blocks’ is closed to new replies.