i have the same question with u,and i don’t know how to solve it now.
A custom theme should be coded which extracts custom post types. At the end of this page
http://www.satollo.net/plugins/newsletter/newsletter-themes
rhere are some tips about custom post types.
Thread Starter
jbx
(@jbx)
Thanks for that Stefano.
Yes I can add the custom post types to the $filters, but how do I edit the theme screen (theme-options.php) to allow the user to choose which post types to include?
I would like to offer checkboxes, like we already do for categories, so that the user can choose to include ‘Posts’ or ‘Events’ in the newsletter.
Thread Starter
jbx
(@jbx)
OK got it now. Actually whatever I put in theme-options.php I can then use in theme.php as filtering criteria.
Would be useful for other people looking for the same thing to have some more info on this in the documentation, or to have it in one of the default themes.
Thanks
See the default theme, it should have all the code.
Thread Starter
jbx
(@jbx)
Do you know if this could have stopped working after the latest updates?
I haven’t touched anything since this post, and everything was working fine, but now my client complained that filtering by post-type is not retrieving anything. The only thing I did recently was update wordpress to version 4.0 and update this plugin to the latest version.
Thanks.
Hi, can you help me to understand? Filtering where? Thank you.
Thread Starter
jbx
(@jbx)
Hi Stefano,
Thanks for replying so quickly.
So I had added in the theme-options.php as we had discussed above a couple of checkboxes to filter custom post-types (like Events for example), so that the user can then send a newsletter with just the events, and in theme.php I had included the check for it so that the items are filtered.
It was working fine till recently. I still get the ‘Events’ checkbox I had added but nothing comes up now (when I am sure there are entries). It also has the same behaviour for other custom post types.
Do you know if anything changed recently that could effect this?
This is the code I have in theme-options.php:
echo '<div class="nl-checkbox-group">';
$controls->checkbox_group('theme_post_types', 'post', 'Posts');
echo '</div>';
echo '<div class="nl-checkbox-group">';
$controls->checkbox_group('theme_post_types', 'event', 'Events');
echo '</div>';
While this is the code in theme.php:
if (is_array($theme_options['theme_post_types']) && count($theme_options['theme_post_types']) > 0)
$filters['post_type'] = $theme_options['theme_post_types'];
else if (isset($theme_options['theme_post_types']))
{
$filters['post_type'] = array();
array_push($filters['post_type'], $theme_options['theme_post_types']);
}
Which is then passed to getposts() as follows:
$posts = get_posts($filters);
Thanks a lot.
Thread Starter
jbx
(@jbx)
Hi again Stefano,
It was an issue with the way the categories were being selected. Nothing from your side!
Thanks anyway!
i need short code of this plugin to use multiple place. please help me.