通过 php wordpress 插件设置侧边栏位置禁用并隐藏页面标题
Set sidebar position disabled and hide page title through php wordpress plugin
我为 wordpress 创建了一个插件,可以按需自动 post 页
我的问题是将此页面格式化为特定模板
我需要当 post 页面自动插入数据库时,将 Sidebar position
设置为禁用以获得全宽页面并隐藏 page title
.. .这个选项出现在仪表盘里,我可以一个一个地点击它们,但是那必须是自动的,不能手动。
$my_post = array(
'post_title' => wp_strip_all_tags( $tituloFichaP1 ),
'post_content' => $content,
'post_status' => 'publish',
'post_author' => 1,
'post_category' => array( 8,39 ),
'post_type' => 'page',
'post_parent' => $parentPost,
'page_template' => 'microsite',
'comment_status' => 'open',
);
wp_insert_post( $my_post );
顺便说一下,page_template 属性 ('page_template' => 'microsite')
也不起作用。 Te post 已插入,但模板设置为默认值。
提前致谢!!!
我刚刚检查了你的代码,你犯了一个简单的错误,在 "page_template" 中应该是你的文件名 (filename.php)模板不是模板名称。例如。如果您的模板 microsite 的 文件名是 microsite.php 那么您的代码将是
$my_post = array(
'post_title' => wp_strip_all_tags( $tituloFichaP1 ),
'post_content' => $content,
'post_status' => 'publish',
'post_author' => 1,
'post_category' => array( 8,39 ),
'post_type' => 'page',
'post_parent' => $parentPost,
'page_template' => 'microsite.php',
'comment_status' => 'open',
);
wp_insert_post( $my_post );
希望对您有所帮助。
我为 wordpress 创建了一个插件,可以按需自动 post 页 我的问题是将此页面格式化为特定模板
我需要当 post 页面自动插入数据库时,将 Sidebar position
设置为禁用以获得全宽页面并隐藏 page title
.. .这个选项出现在仪表盘里,我可以一个一个地点击它们,但是那必须是自动的,不能手动。
$my_post = array(
'post_title' => wp_strip_all_tags( $tituloFichaP1 ),
'post_content' => $content,
'post_status' => 'publish',
'post_author' => 1,
'post_category' => array( 8,39 ),
'post_type' => 'page',
'post_parent' => $parentPost,
'page_template' => 'microsite',
'comment_status' => 'open',
);
wp_insert_post( $my_post );
顺便说一下,page_template 属性 ('page_template' => 'microsite')
也不起作用。 Te post 已插入,但模板设置为默认值。
提前致谢!!!
我刚刚检查了你的代码,你犯了一个简单的错误,在 "page_template" 中应该是你的文件名 (filename.php)模板不是模板名称。例如。如果您的模板 microsite 的 文件名是 microsite.php 那么您的代码将是
$my_post = array(
'post_title' => wp_strip_all_tags( $tituloFichaP1 ),
'post_content' => $content,
'post_status' => 'publish',
'post_author' => 1,
'post_category' => array( 8,39 ),
'post_type' => 'page',
'post_parent' => $parentPost,
'page_template' => 'microsite.php',
'comment_status' => 'open',
);
wp_insert_post( $my_post );
希望对您有所帮助。