I'm creating a Wordpress blog application using timber and twig. The problem is that i want to select all post except for one This is what I have now:
$context = Timber::get_context();
$context['post'] = new Timber\Post(); //the one we don't want
$args = array(
'posts_per_page' => 2,
'post_tag' => $context['post']->post_tag
);
$context['relevant'] = Timber::get_posts($args);//the ones we want
Timber::render(array('single-' . $post->post_type . '.twig', 'single.twig'), $context);
context['post']: contains one single post.
context['relevant'] contains all the posts with te same tag as context['post']
what i exactly want is: if the context['post'] element, is included in the context['relevant'], I want it removed and put in an other post in it instead.
Is there any way to do this?
Any help is much appreciated and thanks in advance.
SOVED
actually really easy, the only thing I had to do was to get het index of the array and then unset is.
$a = array_search($context['post'], $context['relevant']);
unset($context['relevant'][$a]);