Pagebuilder Content

I am currently using a pagebuilder, and it stores content in:
wp_postmeta → meta_value

In that table is also:
wp_postmeta → meta_id
wp_postmeta → post_id
wp_postmeta → meta_key

What is the L&L code for these fields?

Thanks!

Hi @tangiblerun, since I’m not super knowledgeable about how the WordPress database structure works, I had to do a little googling to make sure I had the right info to answer this. I’m not sure how much of this you already know, but I figured I’d share what I learned anyway.

The short answer is that the table you mentioned just contains custom fields, so you can display them the same way you’d display any other field in L&L, using <Field some_field_name />.

The longer answer is that the wp_postmeta table is simply the standard table in which just about all custom fields are stored in WordPress. Those other things you mentioned (meta_id, post_id, and meta_key) are the standard columns that exist in that table. The standard fields on a WordPress post are stored as rows in the wp_posts table and then any custom fields get associated with that post by mentioning the post ID number in that post_id column on the wp_postmeta table.

When you create a query in L&L (usually using the Loop tag), L&L will allow you to display core data from the wp_posts table as well as any custom data associated with those posts in the wp_postmeta table. If I were to create a query of a single post, I could display a core field from wp_posts and a custom field from wp_postmeta in the exact same way, just by referring to the field name that’s found in the meta_key column:

<Loop type=post id=1234>
  <Field title />
  <Field my_custom_field />
</Loop>

Of course, the post type created by your page builder probably isn’t post so you’ll just need to specify the custom post type created by the page builder there instead.

1 Like

Hi Benjamin,

Thanks for explaining. Conceptually I understand this, but practically, I don’t really know where to start in terms of syntax. I haven’t worked with databases like this before.

I tried this, but it didn’t work:

<Loop type=page id=6060>
     <Field meta_value />
</Loop>

One thing that I think might help, is if you could provide a random example of a Loop that displays a custom field from wp_postmeta. Once I see an example, I think I could work out how to do it in my particular use case. I’m also not sure how to identify if the post type created by the page builder is different.

You’re not too far off! That syntax seems correct overall, but part of the reason that wouldn’t work is that meta_value isn’t the name of a custom field, it’s just the name of a column on that database table. Every single custom field on your site exists in that column, so you’d need to know the value of one of the rows. What you would need to specify in that Field tag is the name of whatever field you’re trying to display. You could try writing <Field all /> which would display all the fields available, which is mostly just used for development purposes when you aren’t sure what the field name is.

I should note that if you’re putting your L&L template on the page that contains the field you want to display, you wouldn’t need to wrap it in a loop. That’s because the default loop of the current page already gives L&L the context to know where it should look to find the fields you’re trying to display.

As you mentioned, the other thing you’re going to need to know is the name of the post type you’re trying to display. page is the name of the post type for regular WordPress pages. It could be that your page builder also uses this post type (most builders do, but I haven’t used muffin builder). I can’t tell you the name of the post type you’re looking for, but you could ask the support team for the page builder what that post type is. You might also be able to see the name of the post type in the URL when you’re editing one of their posts. You could try putting this in a template which would show a list of all the post types on your site:

<Loop type=type>
  <p>For the ‘<Field label_plural />’ post type, refer to it using the slug ‘<Field name />’</p>
</Loop>

Ultimately, your syntax seems fine, but you can only display data if you know the field name (and sometimes the post type) that you want to display. Let me know if you’re getting tripped up on certain parts of working with L&L and I’ll try to clarify things. If you haven’t already, you’ll want to go through the beginner’s guide in the docs. You might have an easier time if you stop thinking about trying to display data from specific database tables and instead think about displaying a certain field from a certain post type.

I hope this helps!

Thanks.

I just consulted with a developer and he said it might not be possible to do this, due to the complexity of the way this theme and builder is setup.

This is the way the builder content is shown in the php:
mfn_builder = new Mfn_Builder_Front(get_the_ID());
$mfn_builder->show();

I think this might only be possible with PHP.

Out of curiosity, what are the names of the fields you’re trying to display and where are you trying to display them?

I believe it is stored here,

but I’m not sure the name of the field. Displaying “All fields” didn’t bring up meta_value or anything related to the pagebuilder content.

I am displaying them on another page.