I've got this script to list all the post titles with permalinks including posts that are in the trash, on the front-end:
<ul>
<?php
$myposts = get_posts(array(
'numberposts' => -1,
'offset' => 0,
'category' => $cat_id,
'post_status' => array('publish','trash')
)
);
foreach($myposts as $post) :
setup_postdata($post);
?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endforeach; ?>
<?php wp_reset_postdata(); ?>
</ul>
This works fine. But the problem is if I click on any of the post titles that are in the 'trash', I get the 404 page.
How can I access trashed posts on the front-end? I understand this the default Wordpress behaviour, but is there perhaps a function that allows trash posts to be viewed?
Thanks in advance.