Thread Starter
jhanse
(@jhanse)
Sorry, just found out that the update and this failing was by chance. I have also today tried to get events to show up in archive pages and have used the following code which I guess interferes with the admin area:
function eo_event_archive($query){
if( $query->is_archive() && $query->is_main_query() ){
$query->set('post_type', array('post','event',));
}
}
add_action('pre_get_posts','eo_event_archive');
Any alternatives to display events along with posts in the archives of the page?
Thread Starter
jhanse
(@jhanse)
Nevermind, figured it out, this is the correct code:
function eo_event_archive($query){
if( ! is_admin() && $query->is_archive() && $query->is_main_query() ){
$query->set('post_type', array('post','event',));
}
}
add_action('pre_get_posts','eo_event_archive');
Thanks anyway!
How exactly did you go about doing this? Where does that code go, if you don’t mind me asking? I’m having a similar issue. I am able to see “drafts” and “trash” but “all” and “published” display nothing unless I search for them.
Hi Keven,
I think Jhanse’s problem was caused by an error in some custom code – unless you are also doing that somewhere, I don’t think this will work for you.
The code can either go in a ‘functionality plug-in’ or your theme’s functions.php.