我已经构建了一个简单的销售页面主题,并希望通过允许输入默认内容(包括标题、要点、推荐性blockquotes和无处不在的“添加到购物车”按钮)来对其进行一些增强。
向内容页和/或帖子中添加html片段的选项有哪些?
理想情况下,当我从帖子或页面菜单中单击“添加新内容”时,内容已经预先填充了销售页面的默认内容。
或者更好的是,我可以在“添加新”链接下面添加一个菜单,如“添加新Salespage”,通过单击该菜单,它将默认为sales page内容。
我想在我的主题文件夹中有一个名为salespage的页面。html(或salespage.txt或salespage.php,以更容易使用的为准),这将是用于预填充编辑器的内容。
非常感谢您的帮助。
更新:感谢Chris\\u O下面的回答,我找到了解决方案。我扩充了Chris建议的解决方案,从外部文件加载内容。。。。
if (get_option("cb2_theme") == "salespage")
{
//added to support salespage creation
add_filter( \'default_content\', \'my_editor_content\' );
function my_editor_content( $content ) {
if(file_exists(ABSPATH.\'wp-content/themes/clickbump_wp3/styles/salespage/default-content.html\')){$content = file_get_contents(ABSPATH.\'wp-content/themes/mytheme/styles/salespage/default-content.html\');}else{$content = "Enter your salespage content here. h1-h3 tags, blockquotes etc";}
//$content = "This is some custom content I\'m adding to the post editor because I hate re-typing it.";
return $content;
}
}