Hello,
I’m using the page builder for a new project and it’s always a thrill to use.
However, in this case the designer has come up with an idea i’m not really a fan of, but i have to solve it anyway. Business as usual. I’ve ended up realizing that some post types should have individual headers, specified on each post.
The content of this header will be quite dynamic. My approach is therefore to have a metabox with a button to the Layout builder widget. That is, it should work as if i had a sidebar and added this widget to it.
Any suggestions of how to achieve that? Registering sidebars and in my metabox select a sidebar will not be an acceptable acceptable solution, since there will be quite many sidebars.
Another solution would be to add another wp_editor() to my metabox, but how do i add the tab for siteorigin here?
Ok, i was able to solve the problem. For the one interested in how, this is what i did;
And saves this with
Please come back with better/other soluitons.
And this leads me to question no 2. Now i can admin the content correctly. But how do use this data to render? In my themes header.php i want to render my json string.
This is what i have:
the
takes the post id for checkign the post meta ‘panel data’, but i want to use this function with my stored data above.
Should be a simple task?
Hi Linuzitac,
I’m glad to hear you were able to work with Metabox as desired. I’m sorry I wasn’t able to be of assistance with doing that. I don’t have any suggestions on general improvements – what you’ve done looks fine.
Regarding your second post, it’s possible to pass data using the mentioned method by passing the data through the $panels_data parameter. As an example, you could do something like this:
Hi Alex, and thank you.
The data i have saved is this:
Lets say I got this in a variable called $a.
I have tried:
All of them gives me an empty string.
Any data i need to save that I’ve missed or something?
Hi Linuzitac,
Can you please provide more information on how $a was set? Did you fetch the data and then pass it or did you do any processing before hand?
$a in this case is just metadata I’ve saved for the post.
I have a metabox for handling the post header with a SOW layoutbuilder.
As i tried to describe in the post before, this is what i have;
This is enough data to handle my layout builder in the metabox (with some js ans stuff).
In the theme then get my $a by
I realized that i’m passing a json string to the
When i try
i get
and
Aaaaand that error is because i have json_decode with default false, if i do
it converts to arrays instead of stdClass. This gives me no errors, but still an empty string. :)
Aaaaaaand it works when i echo it… Sorry :)