-
投稿者検索結果
-
2025年10月27日 7:53 AM #146660
返信が含まれるトピック: テンプレート編集で作成したページにナビゲーションを設置したい。
## 既存のテンプレートを希望のレイアウトになるようにカスタマイズする
snow-monkey/template-parts/content/entry/entry.phpの出力をカスタマイズする例です。記事の本文部分のみカスタマイズしたい場合は、snow-monkey/template-parts/content/entry/content/content.phpを対象に変更してください。add_filter( 'snow_monkey_template_part_render_template-parts/content/entry/entry', function ( $html, $name ) { // 投稿タイプが「投稿」のときのみ。 if ( 'post' === $name ) { ob_start(); ?> <article <?php post_class(); ?>> <div class="xxx"> <div class="xxx"> <?php the_post_thumbnail(); ?> </div> <div class="xxx"> <div class="xxx"> <?php the_date(); ?> | <?php the_category(); ?> </div> <div class="xxx"> <?php the_content(); ?> </div> </div> </div> </article> <?php return ob_get_clean(); } return $html; }, 10, 2 );2025年7月3日 4:57 PM #145600返信が含まれるトピック: footerのカスタマイズについて
Snow Monkey が用意しているフッターの種類にはこういうレイアウトは無いので、コーディングしちゃうのが速くて確実かなと思います。
add_filter( 'snow_monkey_template_part_render_footer', function( $html ) { return 'ここに HTML'; } );♥ 0Who liked: No user2025年6月30日 8:00 PM #145568返信が含まれるトピック: 特定の「任意のタクソノミーの投稿」ブロックのリンクを新規ウィンドウで開きたい。
2025年6月30日 3:53 PM #145564返信が含まれるトピック: 特定の「任意のタクソノミーの投稿」ブロックのリンクを新規ウィンドウで開きたい。
has_category( 'demae', $post )となっていますが$postが存在しないためエラーがでちゃうのではないかなと思います。global $postを入れて、グローバル変数の$postを参照するとどうでしょうか?add_filter( 'snow_monkey_template_part_render_template-parts/loop/entry-summary/', function( $html ) { global $post; if ( has_category( 'demae', $post ) ) { $html = str_replace( '<a', '<a target="_blank" rel="noreferrer noopener"', $html ); } return $html; } );2025年6月30日 9:00 AM #145562返信が含まれるトピック: 特定の「任意のタクソノミーの投稿」ブロックのリンクを新規ウィンドウで開きたい。
キタジマ様
ご確認いただきありがとうございます。
やりたいことは、 「任意のタクソノミーの投稿」ブロックでカテゴリーが「demae」の場合、 新規ウィンドウで開きたいです。
下記コードを
my-snow-monkey.phpに追加しましたが、 新規ウィンドウでは開きませんでした。add_filter( 'snow_monkey_template_part_render_template-parts/loop/entry-summary/', function( $html ) { if ( has_category( 'demae', $post ) ) { $html = str_replace( '<a', '<a target="_blank" rel="noreferrer noopener"', $html ); } return $html; } );♥ 0Who liked: No user2025年6月28日 10:56 AM #145549返信が含まれるトピック: 特定の「任意のタクソノミーの投稿」ブロックのリンクを新規ウィンドウで開きたい。
もし「記事に飛ぶリンクを新規ウィンドウで開きたい」であれば、
snow_monkey_template_part_render_template-parts/loop/entry-summaryフックによるカスタマイズで大丈夫なはずです。ただし、
if ( is_category( 'demae' ) || is_category( 'information' ) ) {が問題になると思います。これは今「
demaeカテゴリーアーカイブページを表示している」か「informationカテゴリーアーカイブページを表示している」場合にのみ実行されるので、任意のタクソノミー投稿ブロックが固定ページに設置されている場合は実行されません。♥ 0Who liked: No user2025年6月11日 4:37 PM #145423返信が含まれるトピック: トップページ以外のロゴのタグをdivからh1に変更したい
キタジマ様
h2に変更できました。

c-page-header__titleでもh2に変更できました。
add_filter( 'snow_monkey_template_part_render', function( $html, $slug ) { if ( 'template-parts/common/page-header' === $slug ) { $html = str_replace( ' <h1 ', '<h2 ', $html ); $html = str_replace( ' ', ' ', $html ); return $html; } return $html; }, 10, 2 );トピック閉じます。
2025年6月10日 4:44 PM #145385返信が含まれるトピック: トップページ以外のロゴのタグをdivからh1に変更したい
まーちゅう様
ご返信ありがとうございます、またh1が2つになることを気にしていただき、ありがとうございます。
固定ページと投稿のc-entry__titleは下記ページを参考にh2に変更しました。アーカイブページの
c-entry__titleのh1をh2に変更するのは下記コードであっていますでしょうか。add_filter( 'snow_monkey_template_part_render', function( $html, $slug ) { if ( 'template-parts/archive/entry/header/header' === $slug ) { $html = str_replace( '<h1 ', '<h2 ', $html ); $html = str_replace( '</h1>', '</h2>', $html ); return $html; } return $html; }, 10, 2 );♥ 0Who liked: No user2025年5月17日 5:31 PM #145222返信が含まれるトピック: 投稿一覧ページのフッター上部(コンテンツ下)に各ページ共通のブロックを挿入したい
snow_monkey_template_part_render_footerフィルターフックでフッターの HTML をカスタマイズできます。同期パターンの場合は
apply_filters( 'the_content', '<!-- wp:block {"ref":19703} /-->' )という形でテンプレートから呼び出せます。これを組み合わせて、下記のようなコードでフッターの上部に同期パターンを呼び出せるかなと。My Snow Monkey プラグインにコードを追加して試してみてください!
※
refのところの番号はご自身の環境にあわせて変えてください。僕は記事の編集画面で表示したいパターンを配置して、コードエディターに切り替えて確認しました。add_filter( 'snow_monkey_template_part_render_footer', function( $html ) { return apply_filters( 'the_content', '<!-- wp:block {"ref":19703} /-->' ) . $html; } );2025年2月19日 2:57 PM #144140返信が含まれるトピック: カスタムフィールドで表示している箇所にタグも追加したい
リプライするときに整形されるから?なのかコードが崩れているので整形してみました。
あと、コードの途中にちゃんとタグの情報が取得できているか確認するために
var_dump(...);を追加してみました。ちゃんと取得できているならタグの情報が画面上に表示されるはずです。表示されないなら紐づけができていないか、名前が間違っている可能性がありそうです。add_filter( 'snow_monkey_template_part_render_template-parts/loop/entry-summary/title/title', function ($html) { // カスタムフィールドで設定したフィールド名を代入 $acf_name_area = get_field('name_area'); $acf_region_area = get_field('region_area'); $acf_specialty_genre = get_field('specialty_genre'); // テンプレートのh3タグの後に <div class="property-info">を追加 $acf_property_info = '</h3><div class="property-info">' . '<div class="property-body">' . '<div class="property-content">' . '<dl class="name_area"><span>【代表者名】</span> <dt>' . esc_html($acf_name_area) . '<dt></dl>' . '<dl class="region_area"><span>【地域】</span> <dt>' . esc_html($acf_region_area) . '<dt></dl>' . '<dl class="specialty_genre"><span>【取扱業務】</span> <dt>' . esc_html($acf_specialty_genre) . '<dt></dl>' . '</div>' . '</div>' . '</div>'; // テンプレートパーツのh3タグの後ろにdivタグを追加する $html = str_replace( '</h3>', $acf_property_info, $html ); return $html; // テンプレートパーツのh3タグの後ろにdivタグを追加する $html = str_replace( '</h3>', $acf_property_info, $html ); // 記事に紐づいている post_tag の各タームのアーカイブページへのリンクを表示する $post_tag_terms = get_the_terms(get_the_ID(), 'administrative_scrivener_tag'); var_dump( $post_tag_terms ); // テスト用 ob_start(); if (is_array($post_tag_terms)) { foreach ($post_tag_terms as $post_tag_term) { ?> <a href="<?php echo esc_url( get_term_link( $post_tag_term ) ); ?>"><?php echo esc_html( $post_tag_term->name ); ?></a> <?php } } $administrative_scrivener_tags = ob_get_clean(); var_dump( esc_html( $administrative_scrivener_tags ) ); // テスト用 $html = $html . $administrative_scrivener_tags; return $html; } );2025年2月19日 2:09 PM #144139返信が含まれるトピック: カスタムフィールドで表示している箇所にタグも追加したい
キタジマ様
早速のご教授ありがとうございます。
申し訳ありません、return $html;追加と
タクソノミーnameが「administrative_scrivener_tag」の為
下記の様にpost_tagの箇所を「administrative_scrivener_tag」に変更いたしましたが表示されない様です。add_filter( 'snow_monkey_template_part_render_template-parts/loop/entry-summary/title/title', function ($html) { // カスタムフィールドで設定したフィールド名を代入 $acf_name_area = get_field('name_area'); $acf_region_area = get_field('region_area'); $acf_specialty_genre = get_field('specialty_genre'); // テンプレートのh3タグの後に <div class="property-info">を追加 $acf_property_info = ' <div class="property-info">' . ' <div class="property-body">' . ' <div class="property-content">' . ' <dl class="name_area">【代表者名】 <dt>' . esc_html($acf_name_area) . '</dt> <dt></dt> </dl> ' . ' <dl class="region_area">【地域】 <dt>' . esc_html($acf_region_area) . '</dt> <dt></dt> </dl> ' . ' <dl class="specialty_genre">【取扱業務】 <dt>' . esc_html($acf_specialty_genre) . '</dt> <dt></dt> </dl> ' . ' </div> ' . ' </div> ' . ' </div> '; // テンプレートパーツのh3タグの後ろにdivタグを追加する $html = str_replace( ' ', $acf_property_info, $html ); return $html; // テンプレートパーツのh3タグの後ろにdivタグを追加する $html = str_replace( ' ', $acf_property_info, $html ); return $html; // 記事に紐づいている post_tag の各タームのアーカイブページへのリンクを表示する ob_start(); $post_tag_terms = get_the_terms(get_the_ID(), 'administrative_scrivener_tag'); if (is_array($post_tag_terms)) { foreach ($post_tag_terms as $post_tag_term) { ?> <!--?php echo esc_html($post_tag_term->name); ?--> <!--?php <br ?--> } } $html = $html . ob_get_clean(); return $html; } );ご確認いただけますと幸いです。
お手数おかけいたしますが何卒よろしくお願い申し上げます。
♥ 0Who liked: No user2025年2月19日 9:35 AM #144132返信が含まれるトピック: カスタムフィールドで表示している箇所にタグも追加したい
キタジマ様
早速のご教授ありがとうございます。
下記コードを追加いたしましたが表示されませんでした。
ちなみにですが、CPT UIでタクソノミーを追加して表示させている記事に紐付けしております。
記事自体の表示は、「最近の投稿」で投稿タイプを選んでおります。
add_filter( 'snow_monkey_template_part_render_template-parts/loop/entry-summary/title/title', function ($html) { // カスタムフィールドで設定したフィールド名を代入 $acf_name_area = get_field('name_area'); $acf_region_area = get_field('region_area'); $acf_specialty_genre = get_field('specialty_genre'); // テンプレートのh3タグの後に <div class="property-info">を追加 $acf_property_info = '</h3><div class="property-info">' . '<div class="property-body">' . '<div class="property-content">' . '<dl class="name_area"><span>【代表者名】</span> <dt>' . esc_html($acf_name_area) . '<dt></dl>' . '<dl class="region_area"><span>【地域】</span> <dt>' . esc_html($acf_region_area) . '<dt></dl>' . '<dl class="specialty_genre"><span>【取扱業務】</span> <dt>' . esc_html($acf_specialty_genre) . '<dt></dl>' . '</div>' . '</div>' . '</div>'; // テンプレートパーツのh3タグの後ろにdivタグを追加する $html = str_replace( '</h3>', $acf_property_info, $html ); return $html; // テンプレートパーツのh3タグの後ろにdivタグを追加する $html = str_replace( '</h3>', $acf_property_info, $html ); // 記事に紐づいている post_tag の各タームのアーカイブページへのリンクを表示する ob_start(); $post_tag_terms = get_the_terms(get_the_ID(), 'post_tag'); if (is_array($post_tag_terms)) { foreach ($post_tag_terms as $post_tag_term) { ?> <a href="<?php echo esc_url( get_term_link( $post_tag_term ) ); ?>"><?php echo esc_html( $post_tag_term->name ); ?></a> <?php } } $html = $html . ob_get_clean(); } );`
お手数おかけいたしますが、ご確認の程よろしくお願い申し上げます。
♥ 0Who liked: No user2025年2月6日 10:33 AM #143928返信が含まれるトピック: ランディングページ(ヘッダー・フッターあり)にパンくずリストを出したい
どこに出したいかにもよるかなと思いますが、とりあえずフックで出すことはできます。
add_filter( 'snow_monkey_template_part_render_templates/view/full', function( $html, $name ) { // 固定ページのとき if ( 'page' === $name ) { // ランディングページ(ヘッダー・フッターあり)のとき if ( 'blank-content' === \Inc2734\WP_View_Controller\Bootstrap::get_layout() ) { // パンくずを生成 ob_start(); \Framework\Helper::get_template_part( 'template-parts/common/breadcrumbs' ); $breadcrumbs = ob_get_clean(); // パンくずを出力結果にくっつける $html = $breadcrumbs . $html; } } return $html; }, 10, 2 );表示場所やマークアップを調整したい場合は独自にテンプレートを作ったほうが管理しやすいのかなと思います。
♥ 0Who liked: No user2025年1月27日 5:24 PM #143726返信が含まれるトピック: 投稿アーカイブに投稿タグや任意の要素を追加表示したい
snow_monkey_template_part_render_<slug>
snow_monkey_pre_template_part_render_<slug>
のどちらかのフィルターフックを使用されてはどうでしょうか?/** * @param $html テンプレートパーツの出力HTML * @param $name テンプレートパーツの名前 * @param $vars テンプレートパーツのリクエスト配列 */ add_filter( 'snow_monkey_template_part_render_template-parts/loop/entry-summary/title/title', function( $html ) { $html = str_replace( '書き換え前の文字列', '書き換え後の文字列', $html ); return $html; }, 10 );/** * @param $html テンプレートパーツの出力HTML * @param $name テンプレートパーツの名前 * @param $vars テンプレートパーツのリクエスト配列 */ add_filter( 'snow_monkey_pre_template_part_render_template-parts/loop/entry-summary/title/title', function( $html ) { return 'New HTML'; }, 10 );2024年12月20日 12:30 PM #143279返信が含まれるトピック: 投稿の詳細ページだけアイキャッチ画像を変更したい
投稿一覧はそのままで詳細ページでの表示だけ、ということは、あくまで「その記事の装飾としての画像を変えたい」ということだと思ったので、そのやり方を考えてみました。
※
post_thumbnail_htmlで詳細ページだけ表示を変える場合、OGP 画像や関連記事などに使用される画像も変わってしまう可能性があるのでそれ以外を使ったやり方にしてみました。「アイキャッチ画像の表示」の選択肢によって対応が変わるので、一応それぞれのパターンについて考えてみました。
### 「アイキャッチ画像の位置」が「ページヘッダー」のとき
// テンプレートパーツに画像の URL を差し替えるオプションがあるのでそれを使う。 add_filter( 'snow_monkey_get_template_part_args_template-parts/common/page-header', function( $args ) { $default_image_url = get_template_directory_uri() . '/wp-content/uploads/2024/12/XXXX.jpeg'; $args['vars']['_image'] = '<img src="' . esc_url( $default_image_url ) . '" alt="' . esc_attr( get_the_title() ) . '">'; return $args; } );### 「アイキャッチ画像の位置」が「コンテンツの上」のとき
// オプションは無いのでテンプレートパーツ自体を書き換える。 add_filter( 'snow_monkey_template_part_render_template-parts/content/eyecatch', function( $html ) { if ( ! $html ) { return $html; } $default_image_url = get_template_directory_uri() . '/wp-content/uploads/2024/12/XXXX.jpeg'; $default_image = ob_start(); ?> <div class="c-eyecatch"> <img src="<?php echo esc_url( $default_image_url ); ?>" alt="<?php echo esc_attr( get_the_title() ); ?>"> </div> <?php return ob_get_clean(); } ); -
投稿者検索結果

