Skip to content

Instantly share code, notes, and snippets.

@jarednova
Last active August 29, 2015 13:57
Show Gist options
  • Save jarednova/9922455 to your computer and use it in GitHub Desktop.
Save jarednova/9922455 to your computer and use it in GitHub Desktop.
<?php
$context = Timber::get_context();
$context['work'] = Timber::get_posts('post_type=work&numberposts=25');
$context['posts'] = Timber::get_posts();
Timber::render('index.twig', $context);
@capslockpirate
Copy link

Thanks for all the help!

I understand this, but how can I get this to connect posts to the standard blog page, and work to the work page that i have created in wordpress?

would I..

Timber::render('work.twig', $context);

or should it automatically figure this out?

@jarednova
Copy link
Author

The idea is to avoid automatic in favor of explicit (and hopefully, brief). Your index.twig might look like this:

<section id="posts">
{% for post in posts %}
      {% include "tease-post.twig" %}
{% endfor %}
</section>

<section id="work">
{% for work_item in work %}
     {% include 'tease-work.twig' with {post:work_item} %}
{% endfor %}
</section>

@capslockpirate
Copy link

Sorry to take so much of your time.
I have this sort of working but it is still putting both of these on the same page
(and another issue where it cannot find any of the 'work' posts.

is the upstatement site set up in a way that would work? would it be easier for me to go through those files rather than asking you questions left and right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment