Trying to use a WP shortcode (both in shortcode brick and rich text brick) to pull in custom post content and can’t get it to work…any pointers?
WP Version 6.5.2, Bricks 1.9.8
Front end:
Back end:
Trying to use a WP shortcode (both in shortcode brick and rich text brick) to pull in custom post content and can’t get it to work…any pointers?
WP Version 6.5.2, Bricks 1.9.8
Front end:
Back end:
Sorry…it was for a CPT called “Product details”. I had to create a custom shortcode to get it work. Just in case anyone needs something like this, please feel free to change:
function product_details_content_func() {
$content = '';
$args = array(
'post_type' => 'product-details',
'posts_per_page' => 1,
);
$posts = get_posts($args);
if (!empty($posts)) {
$content = $posts[0]->post_content;
}
return $content;
}
add_shortcode('product_details_content', 'product_details_content_func');
This version of the function retrieves the most recent post of the custom post type “product-details” and returns its content. You can use this shortcode [product_details_content]
in your WordPress posts or pages to display the content of the most recent “product-details” post.