Skip to content

Load reusable components via renderComponent #532

Answered by aaronmeder
pplopx asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @pplopx

This should work inside your page.twig:

{{
    renderComponent(
      'ReusableComponent',
      {
        reusableComponent: get_post(10),
      }
    )
}}

Where 10 would be the ID of your reusable component post that you would like to render.

Is that what you were looking for?

How to reconstruct
To figure this out I've added a reusable component to my page (through the wp-admin editor) and used {{ dump(component) }} inside the pageComponents loop in page.twig to figure out the keys it would return.

All the best from 🇨🇭
Aaron

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@pplopx
Comment options

@aaronmeder
Comment options

Answer selected by pplopx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants