0
Welcome Guest! Login
0 items Join Now

Placing post loop info

    • Bridget's Avatar
    • Bridget
    • Rocketeer
    • Posts: 98
    • Thanks: 4

    Placing post loop info

    Posted 4 years 10 months ago
    • So we are trying to post some loop info such as this:
      codex.wordpress.org/Function_Reference/next_post_link

      But with the twig configuration confused a bit on where to put this. We setup some custom post types with these files:
      themes/helium-gantry-child/single-cameras.php
      themes/helium-gantry-child/views/single-cameras.html.twig
      themes/helium-gantry-child/views/partials/content-single-cameras.html.twig

      WOuld you place loop info in any one of those or somewhere else?

      Typically you put it in the index.php of the theme template but that doesn't seem to be correct.
    • Matt's Avatar
    • Matt
    • Preeminent Rocketeer
    • Posts: 21564
    • Thanks: 3090
    • messin' with stuff

    Re: Placing post loop info

    Posted 4 years 10 months ago
    • There are TWIG/Timber variables for that already

      {{ post.next.link }}
      {{ post.prev.link }}

      You could grab the current post object like this:

      {% set post = wordpress.call('Timber::get_post') %}

      **more here: docs.gantry.org/gantry5/advanced/content-in-particles (click WordPress)

      and then you could stick it all in Custom Particle with TWIG enabled... or you could stick it in a page template where the post object is already fetched as referenced here:

      github.com/gantry/gantry5/issues/1670#issuecomment-260879239


      I reference this page all the time: timber.github.io/docs/reference/timber/

      This is useful for working with ACF: timber.github.io/docs/guides/acf-cookbook/

      Lastly I often look at the ContentArray particle's TWIG (WordPress Posts Particle) that's bundled in Gantry Core for code examples on fetching posts with query stings and filters
    • Last Edit: 4 years 10 months ago by Matt.
    • SEARCH the forum first! These boards are rich in knowledge and vast in topics. This includes searching just the 'Solved' forums, using Google, and using ChatGPT :woohoo:

Time to create page: 0.048 seconds