私は簡単なセールスページのテーマを作成し、デフォルトのコンテンツ(ヘッダー、箇条書き、紹介文の引用、そして普遍的な「カートに追加」ボタンを含む)の入力を許可することによってそれを少し高めたいと思います。
コンテンツページや投稿にHTMLスニペットを追加するためのオプションは何ですか?
理想的には、[投稿]または[ページ]メニューから[新規追加]をクリックしたときに、コンテンツに販売ページのデフォルトコンテンツが既に入力されているはずです。
あるいはもっと良いのは、 "Add New Salespage"のような "Add New"リンクの下にメニューを追加し、それをクリックすることでそれがデフォルトのセールスページコンテンツになるということです。
私のテーマフォルダにsalespage.html(またはsalespage.txt、salespage.phpのどちらを使ってもよい)というページを作成したいのですが、これがエディタの事前入力に使用されるコンテンツになります。
任意の助けは大歓迎です。
更新:下記のChris_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;
}
}
@ Scott B、私はこの同じ問題に関して Justin Tadlocksブログ で記事を読みました。
解決策
default_content
フィルタフックを使い、それをthemesのfunction.phpファイルに渡します。
例:
<?php
add_filter( 'default_content', 'my_editor_content' );
function my_editor_content( $content ) {
$content = "This is some custom content I'm adding to the post editor because I hate re-typing it.";
return $content;
}
?>
あなたはXHTMLかあなたが望む何でも$ content文字列に追加することができます
[新しい投稿を追加]をクリックすると表示されます。