મુખ્ય સામગ્રીને બાયપાસ કરો

importThemeStarterContent

Callable


  • Imports a theme's starter content into WordPress and publishes it. The theme must already be installed. If it has no starter content, this step does nothing.

    To import starter content when installing a theme, use installTheme with options.importStarterContent set to true. Use this standalone step when you need to add or modify starter content after installing the theme and before importing it.

    For example, this complete Blueprint writes and activates a plugin that registers a Home page as starter content for the active theme, then imports it and sets it as the site's front page. The plugin runs on after_setup_theme at priority 100, after callbacks with lower priorities, and replaces previously registered starter content. Callbacks registered later at priority 100, or at a higher priority, can replace this content again before it is imported. All plugin code is included inline; no external PHP file is needed.

    {
    "steps": [
    {
    "step": "writeFile",
    "path": "/wordpress/wp-content/plugins/theme-starter-content.php",
    "data": "<?php\n// Plugin Name: Theme Starter Content\nadd_action( 'after_setup_theme', function () {\n add_theme_support( 'starter-content', array(\n 'posts' => array(\n 'home' => array(\n 'post_type' => 'page',\n 'post_title' => 'Home',\n 'post_content' => 'Welcome to my Playground!'\n )\n ),\n 'options' => array(\n 'show_on_front' => 'page',\n 'page_on_front' => '{{home}}'\n )\n ) );\n}, 100 );"
    },
    {
    "step": "activatePlugin",
    "pluginPath": "theme-starter-content.php"
    },
    {
    "step": "importThemeStarterContent"
    }
    ]
    }

    Learn more about supported content and placeholders in Starter content for themes in 4.7.


    Parameters

    Returns any