Is it possible to render Bricks page content via the Code block? What I want to do is essentially get the page content (created with Bricks) from the database, and render it inside the Bricks Builder.
Here’s how I can get the Bricks content:
$post_content = $wpdb->get_var( $wpdb->prepare(
"SELECT meta_value
FROM wp_postmeta
WHERE post_id = %d
AND meta_key = '_bricks_page_content_2'",
$post_ID
));
In other words, I want to insert a Bricks “Template” into my page, but manually (not with Bricks’s in-build “Template” block).
I realise that I could just put the $post_id into bricks_template shortcode, but the $post_id comes from a table that does not belong to the same website. Thus I need to retrieve the data using $wpdb.
This does import the content, but doesn’t import any of the classes or styling of course, so it’s probably a lot more involved that I’d like. Unless anyone has an easier and better suggestion, I think this might be one for the archive.
are you inside a multisite environment?
if so, you probably testet out the render_shortcode function in combination with switch_to_blog()?
I didn’t quite get it to work back when I last tried, but you will get some things rendered (if I remember correctly). I might try again when i have the time and let you know.
thank you very much for ur code. it really helped.
i made some changes. some times the page is made by Gutenberg and some times with bricks. so this code can tell:
as you see the id of each page is mentioned in each line
to use this code u need to make the css codes external, so go to : bricks → settings → performance → CSS loading method
and then “external files” and then “regenerate css files”