bricks_create_post
Overview
Create a new WordPress post in any post type (post, page, or custom post type) with full support for meta fields, ACF fields, featured images, and taxonomy term assignments — all in a single API call.
This is the primary tool for populating content in custom post types. After registering a CPT with bricks_register_post_type and setting up ACF fields, use this tool to create the actual content entries that query loops and dynamic data will display.
Key Features
When to Use
Creating blog posts or pages programmatically with meta fields and taxonomy terms
Setting up sample/seed data for development and testing
Creating posts with ACF field values and featured images in a single call
For ACF meta fields: ACF plugin must be active with the field group configured for the post type
For featured images: upload the image first with bricks_upload_media to get the attachment ID
For taxonomy terms: the taxonomy must exist and terms must be created (use bricks_create_term)
When NOT to Use
Updating existing posts — this tool only creates new posts
You need to create the post type first — use bricks_register_post_type before creating posts in a CPT
Parameters
post_typestringoptionalposttitlestringREQUIREDcontentstringoptionalexcerptstringoptionalstatusstringoptionaldraft Values: draft, publish, pending, privateslugstringoptionalparentnumberoptionalmenu_ordernumberoptionalfeatured_imagenumberoptionalmetaobjectoptionaltaxonomiesobjectoptionalCode Examples
Warning: Undefined array key "example_output" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 12
Create a portfolio item with ACF fields and taxonomy
Create a portfolio CPT entry with custom meta fields, a featured image, and taxonomy term assignment.
// First upload the featured image
const media = await bricks_upload_media({
url: "https://example.com/project-hero.jpg",
filename: "project-webapp.jpg",
alt_text: "Web application dashboard screenshot"
});
// Then create the post with all data in one call
bricks_create_post({
post_type: "portfolio",
title: "SaaS Dashboard Redesign",
content: "<p>A complete redesign of the analytics dashboard...</p>",
excerpt: "Modern SaaS dashboard with real-time analytics",
status: "publish",
featured_image: media.id,
meta: {
"project_url": "https://example.com",
"client_name": "TechCorp",
"project_year": "2025",
"technologies": "React, TypeScript, Tailwind"
},
taxonomies: {
"project_type": [5],
"skill": [12, 15, 18]
}
});Common Mistakes
Warning: Undefined array key "fix_description" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 47
Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-includes/kses.php on line 2018
Warning: Undefined array key "wrong_code" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 48
Warning: Undefined array key "right_code" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 49
Warning: Undefined array key "fix_description" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 47
Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-includes/kses.php on line 2018
Warning: Undefined array key "wrong_code" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 48
Warning: Undefined array key "right_code" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 49
Warning: Undefined array key "fix_description" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 47
Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-includes/kses.php on line 2018
Warning: Undefined array key "wrong_code" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 48
Warning: Undefined array key "right_code" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 49
Tips & Warnings
Create content AFTER setting up the CPT and ACF fields. The workflow is: register post type → create ACF field group → create taxonomy terms → create posts with meta and terms.
The meta parameter works with ACF fields when ACF is active. Use the ACF field name (not the field key) as the meta key.
Use status: « publish » for content that should be immediately visible. Use « draft » for content that needs review.