「snow_monkey_get_template_part_args」の検索結果

15件の結果を表示中 - 16 - 30件目 (全112件中)
  • 投稿者
    検索結果
  • #126624
    キタジマ タカシ
    参加者
    2234

    こんな感じでどうですかね?

    add_filter(
    	'snow_monkey_get_template_part_args',
    	function( $args ) {
    		// 記事一覧カテゴリー以外のテンプレートの場合は無視
    		if ( 'template-parts/loop/entry-summary/term/term' !== $args['slug'] ) {
    			return $args;
    		}
    
    		// 投稿以外の場合は無視
    		if ( 'post' !== $args['name'] ) {
    			return $args;
    		}
    
    		$new_terms = array();
    		$terms     = get_the_terms( get_the_ID(), 'category' );
    		foreach ( $terms as $term ) {
    			$term_ids = get_ancestors( $term->term_id, 'category', 'taxonomy' );
    			krsort( $term_ids );
    
    			// チェックしたカテゴリーと先祖のカテゴリー情報をカテゴリーラベルとして使用
    			foreach ( $term_ids as $term_id ) {
    				$new_terms[ $term_id ] = get_term( $term_id, 'category' );
    			}
    			$new_terms[ $term->term_id ] = $term;
    		}
    		$args['vars']['_terms'] = $new_terms;
    
    		return $args;
    	}
    );
    1
    いいねをした人:
    #126619
    キタジマ タカシ
    参加者
    2234

    末端カテゴリーのみにチェックを変える事も可能です。

    末端カテゴリーのみにチェックした場合の想定でコードを書いてみました。

    add_filter(
    	'snow_monkey_get_template_part_args',
    	function( $args ) {
    		// 記事一覧カテゴリー以外のテンプレートの場合は無視
    		if ( 'template-parts/loop/entry-summary/term/term' !== $args['slug'] ) {
    			return $args;
    		}
    
    		// 投稿以外の場合は無視
    		if ( 'post' !== $args['name'] ) {
    			return $args;
    		}
    
    		$terms = get_the_terms( get_the_ID(), 'category' );
    		if ( $terms ) {
    			// チェックしたカテゴリーを元にその先祖カテゴリーを取得
    			$term      = $terms[0];
    			$term_ids  = get_ancestors( $term->term_id, 'category', 'taxonomy' );
    
    			// チェックしたカテゴリーと先祖のカテゴリー情報をカテゴリーラベルとして使用
    			$new_terms = array();
    			foreach ( $term_ids as $term_id ) {
    				$new_terms[] = get_term( $term_id, 'category' );
    			}
    			krsort( $new_terms );
    			$new_terms[]            = $term;
    			$args['vars']['_terms'] = $new_terms;
    		}
    
    		return $args;
    	}
    );
    5
    いいねをした人:
    mrc
    参加者

    【お使いの Snow Monkey のバージョン】
    バージョン: 20.1.0
    【お使いの Snow Monkey Blocks のバージョン】
    バージョン 19.3.2
    【お使いの Snow Monkey Editor のバージョン】
    バージョン 9.2.5
    【お使いの Snow Monkey Forms のバージョン】
    バージョン 5.0.7
    【お使いのブラウザ】
    Chrome
    【当該サイトのURL】

    ### 実現したいこと

    投稿一覧(リッチメディア)で、新しく投稿されたものに関しては、カテゴリラベルのところにNewマークがつくようにしたい。
    加えて、新しく投稿されたもの(Newマークがつくもの)以外のカテゴリラベルの表示位置を変更したい。
    ※Newマークがついたものは、一定期間が過ぎたら他と同じく、変更した表示位置にカテゴリ表示されるようにしたいです。

    ### 発生している問題

    投稿一覧で、「新しく投稿されたものに関してはカテゴリラベルのところにNewマークがつくようにする」というのは他の質問トピックを参考にして設定することができました。
    新しく投稿されたもの(Newマークがつくもの)以外のカテゴリラベルの表示位置を変更するということに関しては、cssで挑戦してみたものの、Newマークを含む全てのラベルに反映されてしまうのでできませんでした。

    Newマークがつくようにするものと、その他のもの、という条件で分けるカスタマイズをする必要がありますでしょうか?

    ### 試したこと

    「新しく投稿されたものに関してはカテゴリラベルのところにNewマークがつくようにする」は以下のコードを加えました。

    add_filter(
    ‘snow_monkey_get_template_part_args_template-parts/loop/entry-summary/term/term’,
    function( $args ) {
    $days = 3; // NEWマークを表示する日数
    $now = date_i18n( ‘U’ ); // 今の時間
    $entry = get_the_time( ‘U’ ); // 投稿日の時間
    $term = date( ‘U’,( $now – $entry ) ) / 86400;
    if ( $days > $term ) {
    $new_term = new stdClass();
    $new_term->taxonomy = ‘my-new’;
    $new_term->term_id = 0;
    $new_term->name = ‘NEW’;
    $args[‘vars’][‘_terms’] = [ $new_term ];
    }

    return $args;
    }
    );

    また、こちらのトピックを参考にラベルの表示位置を変更しようとしたのですが、できませんでした。

    #118994
    akosan
    閲覧者
    31

    >キタジマさん

    ありがとうございます。category → post_tag へ変更してCSSも変更しました。

    表示が出てこなかったので調べて以下のようにやってみたのですが変更できず行き詰まっています。

    // 投稿以外の場合は無視

    if ( 'post' !== $args['name'] ) { return $args; }
    

    このpostの部分をカスタム投稿に変更しなければならないのでは?と考え

    // カスタム投稿以外の場合は無視
    if ( 'custom_post_type' !== $args['name'] ) {
    	return $args;
    }

    にしてみました。おそらく思い切り間違えてると思いますが…
    勉強不足で申し訳ないです。

    以下変更してUPしたものです。

    お手数ではありますがご指摘よろしくお願いいたします。

    php

    /**
     * Snow Monkey 投稿の一覧で、カスタム投稿のみタグを複数表示にする
     */
    add_filter(
    	'snow_monkey_get_template_part_args',
    	function( $args ) {
    		// 記事一覧カテゴリー以外のテンプレートの場合は無視
    		if ( 'template-parts/loop/entry-summary/term/term' !== $args['slug'] ) {
    			return $args;
    		}
    
    		// カスタム投稿以外の場合は無視
    		if ( 'custom_post_type' !== $args['name'] ) {
    			return $args;
    		}
    
    		// 全ての設定されたタグを返す
    		$args['vars']['_terms'] = get_the_terms( get_the_ID(), 'post_tag' );
    
    		return $args;
    	}
    );

    CSS

    /*カスタム投稿のみ最新の投稿にスラッグを複数ラベル表示*/
    
    .c-entry-summary--lessons .c-entry-summary__figure span:nth-of-type(2){
      top: 2.5em;
    }
    
    .c-entry-summary--lessons .c-entry-summary__figure span:nth-of-type(3){
      top: 5em;
    }
    
    .c-entry-summary--lessons .c-entry-summary__figure span:nth-of-type(4){
      top: 7.5em;
    }
    
    .c-entry-summary--lessons .c-entry-summary__figure span:nth-of-type(n + 5){
      display:none;
    }
    0
    いいねをした人: 居ません
    akosan
    閲覧者

    【お使いの Snow Monkey のバージョン】バージョン: 19.1.6
    【お使いの Snow Monkey Blocks のバージョン】バージョン 18.1.7
    【お使いの Snow Monkey Editor のバージョン】バージョン 9.1.2
    【お使いのブラウザ】chrome
    【当該サイトのURL】https://sora-sanpo.com/_lib/lesson

    ### 実現したいこと

    最新の投稿(カスタム投稿タイプを選択)で表示した際に、タグに入力した単語をラベルで複数(予定では最大3つ)表示したい。

    プラグインcustom post type uiでカスタム投稿タイプを作成。

    表示したいページ:固定ページ
    使用ブロック:最近の投稿(カスタム投稿タイプ)で「各項目のカテゴリーラベルを強制的に表示する」をON
    レイアウト:リッチメディア
    カスタム投稿タイプ 投稿タイプスラッグ:lessons

    ### 発生している問題

    こちらの記事を参考にMy Snow Monkey プラグインとCSSを変更してみましたが、反映されませんでした。

    PHP

    add_filter(
    	'snow_monkey_get_template_part_args',
    	function( $args ) {
    		// 記事一覧カテゴリー以外のテンプレートの場合は無視
    		if ( 'template-parts/loop/entry-summary/term/term' !== $args['slug'] ) {
    			return $args;
    		}
    
    		// 投稿以外の場合は無視
    		if ( 'post' !== $args['name'] ) {
    			return $args;
    		}
    
    		// 全ての設定されたカテゴリーを返す
    		$args['vars']['_terms'] = get_the_terms( get_the_ID(), 'category' );
    
    		return $args;
    	}
    );

    CSS

    .c-entry-summary--post .c-entry-summary__figure span:nth-of-type(2){
      top: 2.5em;
    }
    
    .c-entry-summary--post .c-entry-summary__figure span:nth-of-type(3){
      top: 5em;
    }
    
    .c-entry-summary--post .c-entry-summary__figure span:nth-of-type(4){
      top: 7.5em;
    }
    
    .c-entry-summary--post .c-entry-summary__figure span:nth-of-type(n + 5){
      display:none;
    }

    ### 試したこと

    上記コードを試してみましたが動きませんでした。

    大変お手数ではありますがご教示いただけると幸いです。

    #117170
    キタジマ タカシ
    参加者
    2234

    こんな感じでしょうか。

    add_filter(
    	'snow_monkey_get_template_part_args',
    	function( $args ) {
    		// 記事一覧カテゴリー以外のテンプレートの場合は無視
    		if ( 'template-parts/loop/entry-summary/term/term' !== $args['slug'] ) {
    			return $args;
    		}
    
    		// 投稿以外の場合は無視
    		if ( 'post' !== $args['name'] ) {
    			return $args;
    		}
    
    		// 全ての設定されたカテゴリーを返す
    		$terms = get_the_terms( get_the_ID(), 'category' );
    		$parent_terms = [];
    		$child_terms  = [];
    		foreach ( $terms as $term ) {
    			if ( ! $term->parent ) {
    				$parent_terms[] = $term;
    			} else {
    				$child_terms[] = $term;
    			}
    		}
    		$args['vars']['_terms'] = array_merge( $parent_terms, $child_terms );
    
    		return $args;
    	}
    );

    表示させたい条件によって変わってくると思うので、上記を参考に調整してください。

    1
    いいねをした人:
    #117143
    林田大平
    参加者
    12

    ありがとうございます。
    My Snow Monkeyに下記コードを記述していますが、どこに反映させればよいでしょうか。

    add_filter(
    	'snow_monkey_get_template_part_args',
    	function( $args ) {
    		// 記事一覧カテゴリー以外のテンプレートの場合は無視
    		if ( 'template-parts/loop/entry-summary/term/term' !== $args['slug'] ) {
    			return $args;
    		}
    
    		// 投稿以外の場合は無視
    		if ( 'post' !== $args['name'] ) {
    			return $args;
    		}
    
    		// 全ての設定されたカテゴリーを返す
    		$args['vars']['_terms'] = get_the_terms( get_the_ID(), 'category' );
    
    		return $args;
    	}
    );
    0
    いいねをした人: 居ません
    bsdservice
    参加者
    5

    ページタイトルに関する他のコードをコメントアウトして、上記の記述をコピペしましたが、ページタイトルを変更することができませんでした。

    ちなみにカスタム投稿タイプは「Custom Post Type UI」を使用しています。

    GONSYさんが試してくださった環境と同じ事がしたいのですが、なぜコピペでもうまくいかないのか分かりません。

    ちょっと長くなってしまいますが、my-snow-monkey.phpの中身を載せます。

    <?php
    /**
     * Plugin name: My Snow Monkey
     * Description: このプラグインに、あなたの Snow Monkey 用カスタマイズコードを書いてください。
     * Version: 0.2.1
     *
     * @package my-snow-monkey
     * @author inc2734
     * @license GPL-2.0+
     */
    
    /**
     * Snow Monkey 以外のテーマを利用している場合は有効化してもカスタマイズが反映されないようにする
     */
    $theme = wp_get_theme( get_template() );
    if ( 'snow-monkey' !== $theme->template && 'snow-monkey/resources' !== $theme->template ) {
    	return;
    }
    
    /**
     * Directory url of this plugin
     *
     * @var string
     */
    define( 'MY_SNOW_MONKEY_URL', untrailingslashit( plugin_dir_url( __FILE__ ) ) );
    
    /**
     * Directory path of this plugin
     *
     * @var string
     */
    define( 'MY_SNOW_MONKEY_PATH', untrailingslashit( plugin_dir_path( __FILE__ ) ) );
    
    // 実際のページ用の CSS 読み込み
    add_action(
    	'wp_enqueue_scripts',
    	function() {
    		wp_enqueue_style(
    			'my-snow-monkey',
    			MY_SNOW_MONKEY_URL . '/style.css',
    			[ Framework\Helper::get_main_style_handle() ],
    			filemtime( MY_SNOW_MONKEY_PATH . '/style.css' )
    		);
    		wp_enqueue_script('my_script',MY_SNOW_MONKEY_URL .'/main.js');
    	}
    );
    
    // エディター用の CSS 読み込み
    // クラシックエディターとブロックエディターの両方に CSS が読み込まれます。
    // ブロックエディターの場合は自動的に .editor-styles-wrapper でラップされます。
    // 依存関係は指定できません。
    add_action(
    	'after_setup_theme',
    	function() {
    		add_theme_support( 'editor-styles' );
    		add_editor_style( '/../../plugins/my-snow-monkey/style.css' );
    	}
    );
    
    add_filter(
    'snow_monkey_template_part_render_template-parts/loop/entry-summary',
    	function( $html ) {
    	if ( 'voice' === get_post_type() ):
    	ob_start();
    	?>
    	<?php
    		// カスタムフィールド:概要欄 → event_txt
    		// ACF テキストエリア(改行:なにもしない)
    		$city = get_field( 'ff_city' )
    	?>
    
    	<p class="list-city"><?php echo esc_attr( $city) ; ?><?php if(get_field('ff_type')) :?> <?php echo esc_html (get_field('ff_type')); ?><?php endif; ?></p>
    
    	<?php
    	$voice = ob_get_clean();
    	
    	return str_replace(
    	'</header>',
    	'</header>'.$voice , // 投稿タイトルの下に追加
    	
    	$html
    	);
    	endif;
    	return $html;
    	}
    );
    
    add_filter(
    	'snow_monkey_template_part_render_template-parts/content/entry/header/header',
    	function ( $html ) {
    		if ( is_single()) {
    			?>
    				<header class="c-entry__header">
    					<h1 class="c-entry__title">
    			<?php
    			if ( has_term('local-tour','newscat')   ) {
    				?>
    				完成見学会/オープンハウス<span>宮下工務店のお家をぜひご体感ください</span>
    				<?php
    			}
    			elseif ( is_singular('news')  ) {
    				?>
    				セミナー:見学会
    				<?php
    			}
    			elseif ( is_singular('land')  ) {
    				?>
    				土地情報
    				<?php
    			}
    			elseif ( is_singular('voice')  ) {
    				?>
    				お客様の声
    				<?php
    			}
    			elseif ( is_singular('works')  ) {
    				?>
    				施工事例
    				<?php
    			}
    			else{
    				?>
    				お知らせ
    				<?php
    			}
    			?>
    				</h1></header>
    			<?php
    		return;
    		}elseif ( is_page( '635' ) ) {
    			?>
    				<header class="c-entry__header">
    					<h1 class="c-entry__title">会社案内
    				</h1></header>
    			<?php
    		return;
    		}
    		return $html;
    	}
    );
    
    //記事の場合はコンテンツの上にブログタイトル表示
    add_filter(
    	'the_content',
    	function ( $content ) {
    		if ( is_singular('voice') ) {
    			$city = '<div class="single-voice-top"><p class="city-name">' . get_field('ff_city') . '</p>';
    			if(get_field('ff_type')){
    				$type = '<span class="voice-type">' . get_field('ff_type') . '</span>';
    			}
    			$cityend = '</div>';
    			$page_title = '<h2 class="voice-page-title">' . get_the_title() . '</h2>';
    			$date = '<span class="single-date">' . get_the_date() . '</span>';
    			$content = $city . $type . $cityend . $page_title . $date . $content;
    			return $content;
    		}elseif ( is_singular('works') ) {
    			$date = '<span class="single-date">' . get_the_date() . '</span>';
    			$content = $page_title . $date . $content;
    			return $content;
    		}elseif ( has_term('local-tour','newscat') ) {
    			$page_title = '<h2 class="title-local-tour mincho">' . get_the_title() . '</h2>';
    			$content = $page_title . $content;
    			return $content;
    		}elseif ( is_single() ) {
    			$page_title = '<h2 class="original-page-title">' . get_the_title() . '</h2>';
    			$date = '<span class="single-date">' . get_the_date() . '</span>';
    			$content = $page_title . $date . $content;
    			return $content;
    		}
    		return $content;
    	}
    );
    
    //投稿一覧ブロックサムネ上子カテ表示
    add_filter(
    	'snow_monkey_get_template_part_args_template-parts/loop/entry-summary/term/term',
    	function( $args ) {
    		// カテゴリーアーカイブあるいはタクソノミーアーカイブのとき
    		if ( is_category() || is_tax() ) {
    			// ページのクエリ情報を取得
    			$queried_object = get_queried_object();
    			// その投稿に割当てられているカテゴリー(タクソノミー)を全て取得
    			$terms = get_the_terms( get_the_ID(), $queried_object->taxonomy );
    			// 取得したカテゴリー(タクソノミー)のうち、最後のタームをカテゴリーラベルとして使用する
    			$args['vars']['_terms'] = [ end( $terms ) ];
    		}
    		return $args;
    	}
    );
    
    //土地情報・セミナー・イベントの詳細ページ上部の指定
    
    add_action(
    	'snow_monkey_before_entry_content',
    	function() {
                if ( is_singular('land') ){
    		?>
    		<?php
    		$terms = get_the_terms($post->ID, 'landcat');
    		if ($terms) : ?>
    			<ul class="single-works-cat">
    			<?php
    			foreach ($terms as $term) {
    			echo '
  • ' . $term->name . '
  • '; } ?> <?php endif; ?> <?php }elseif ( is_singular('news') && !has_term('local-tour','newscat')) { ?> <div class="wrap-content"> <?php } } ); //土地情報の詳細ページの指定 add_action( 'snow_monkey_after_entry_content', function() { if ( is_singular('land') ){ ?> <div class="land-data"> <?php if(get_field('ff_list')) :?> <p class="land-hade"><?php the_field('ff_list'); ?></p> <?php endif; ?> <?php if(get_field('price-detail')) :?> <dl><dt>価格</dt><dd><?php the_field('price-detail'); ?></dd></dl> <?php endif; ?> <?php if(get_field('area-detail')) :?> <dl><dt>面積</dt><dd><?php the_field('area-detail'); ?></dd></dl> <?php endif; ?> <?php if(get_field('list')) :?> <dl><dt>checkmark</dt><dd><?php the_field('list'); ?></dd></dl> <?php endif; ?> <?php if(get_field('ff_photo')) :?> <div class="land-detail-img">" alt="" /></div><!-- /.land-detail-img --> <?php endif; ?> <?php if(get_field('ff_th01')) :?> <dl><dt>所在地</dt><dd><?php the_field('ff_th01'); ?></dd></dl> <?php endif; ?> <?php if(get_field('ff_th02')) :?> <dl><dt>交通</dt><dd><?php the_field('ff_th02'); ?></dd></dl> <?php endif; ?> <?php if(get_field('ff_text01')) :?> <dl><dt>教育施設</dt><dd><?php the_field('ff_text01'); ?></dd></dl> <?php endif; ?> <?php if(get_field('ff_text02')) :?> <dl><dt>医療施設</dt><dd><?php the_field('ff_text02'); ?></dd></dl> <?php endif; ?> <?php if(get_field('ff_th03')) :?> <dl><dt>都市計画</dt><dd><?php the_field('ff_th03'); ?></dd></dl> <?php endif; ?> <?php if(get_field('ff_th04')) :?> <dl><dt>地目</dt><dd><?php the_field('ff_th04'); ?></dd></dl> <?php endif; ?> <?php if(get_field('ff_th05')) :?> <dl><dt>建ぺい率</dt><dd><?php the_field('ff_th05'); ?></dd></dl> <?php endif; ?> <?php if(get_field('ff_th06')) :?> <dl><dt>容積率</dt><dd><?php the_field('ff_th06'); ?></dd></dl> <?php endif; ?> <?php if(get_field('ff_th07')) :?> <dl><dt>道路</dt><dd><?php the_field('ff_th07'); ?></dd></dl> <?php endif; ?> <?php if(get_field('ff_th08')) :?> <dl><dt>引渡日</dt><dd><?php the_field('ff_th08'); ?></dd></dl> <?php endif; ?> <?php if(get_field('ff_th09')) :?> <dl><dt>取引態様</dt><dd><?php the_field('ff_th09'); ?></dd></dl> <?php endif; ?> <?php if(get_field('ff_th10')) :?> <dl><dt>備考</dt><dd><?php the_field('ff_th10'); ?></dd></dl> <?php endif; ?> </div> /contact/?post_id=<?php the_ID(); ?>" class="btn-single-land">この記事について問い合わせる land">一覧に戻る <?php $terms = get_the_terms($post->ID, 'landtag'); if ($terms) : ?> <p>【関連タグ】</p> <ul class="single-works-tag"> <?php foreach ($terms as $term) { echo '
  • ' . $term->name . '
  • '; } ?> <?php endif; ?> <?php } } ); //土地情報ターム一覧ページタイトル add_filter( 'snow_monkey_template_part_render_template-parts/common/page-header', function( $html ) { if ( is_tax( 'landcat' ) || is_post_type_archive( 'land' ) ) { $html = preg_replace( '|(<h1 class="c-page-header__title">.*?</h1>)|ms', '<h1 class="c-page-header__title">土地情報</h1>', $html ); } return $html; }, 10 ); // 土地情報一覧ページ 一覧上の文章 add_action( 'snow_monkey_before_archive_entry_content', function() { if ( is_post_type_archive('land') ){ ?> <div class="land-list-text"> <p>最新情報を続々アップしています!</p> <p>初生・三方原地区を中心に土地物件情報をお届けしています。<br /> 南区、中区もご相談ください。</p> </div> <?php } } ); // 土地情報一覧ページ 記事ブロックの内容 add_filter( 'snow_monkey_template_part_render_template-parts/loop/entry-summary', //entry-summary-postが対象 function( $html ) { if (get_post_type() === 'land'): //カスタム投稿landに限定する // 以降の出力を変数に格納する ob_start(); ?> <?php if(has_term('pickup','landcat')): ?> <span class="pickup-circle">PICK UP</span> <?php endif; ?> <div class="land-list-data"> <?php if(get_field('price')) :?> <dl> <dt>価格</dt> <dd> <?php echo esc_html (get_field('price')); ?> <?php if(has_term('free','landcat')): ?> <span class="tag-free">仲介手数料不要</span> <?php endif; ?> </dd> </dl> <?php endif; ?> <?php if(get_field('area')) :?> <dl><dt>面積</dt><dd><?php echo esc_html (get_field('area')); ?></dd></dl> <?php endif; ?> </div> <?php // 変数に格納する $type = ob_get_clean(); // </header>を書き換える return str_replace( '</header>', '</header>'.$type, $html ); endif; return $html; } ); // 施工事例一覧ページ 一覧上の文章 add_action( 'snow_monkey_before_archive_entry_content', function() { if ( is_post_type_archive('works') || is_tax('workscat') ){ ?> <ul class="nav-works">
  • /workscat/new-construction/">新築
  • /workscat/reform/">リフォーム
  • /workscat/parts/">パーツギャラリー
  • <?php } } ); //施工事例の詳細ページの指定 add_action( 'snow_monkey_before_entry_content', function() { if ( is_singular('works') ){ ?> <ul class="nav-works">
  • /workscat/new-construction/">新築
  • /workscat/reform/">リフォーム
  • /workscat/parts/">パーツギャラリー
  • <h2 class="original-page-title"><?php echo get_the_title(); ?></h2> <?php $terms = get_the_terms($post->ID, 'workscat'); if ($terms) : ?> <ul class="single-works-cat"> <?php foreach ($terms as $term) { echo '
  • ' . $term->name . '
  • '; } ?> <?php endif; ?> <?php } } ); //施工事例の詳細ページ下部の指定 add_action( 'snow_monkey_after_entry_content', function() { if ( is_singular('works') ){ ?> <?php $terms = get_the_terms($post->ID, 'workstag'); if ($terms) : ?> <p>【関連タグ】</p> <ul class="single-works-tag"> <?php foreach ($terms as $term) { echo '
  • ' . $term->name . '
  • '; } ?> <?php endif; ?> <?php } } ); //記事の詳細ページの指定 add_action( 'snow_monkey_after_entry_content', function() { if ( has_term('local-tour','newscat') ){ ?> <section class="wrap-tour-standard"> <div class="tour-standard"> <h4 class="mincho">宮下工務店の3つのスタンダード</h4> <div class="tour-standard-box"> <div class="tour-left"> <p>外断熱</p> <p>耐震<br>耐久性</p> <p>自然<br>素材</p> </div><!-- /.tour-left --> <div class="tour-right"> <p>安心・快適に過ごしていただくため、<br>宮下工務店では標準仕様を設けております</p> /new-construction/">標準仕様を詳しく見る </div><!-- /.tour-right --> </div><!-- /.tour-standard-box --> </div><!-- /.wrap-tour-standard --> </section> <div class="tour-contact01"> <p>完全予約制となります。お電話または予約フォームよりご予約ください</p> <div class="btn-tour-contact01"> 053-437-2695 /contact/?post_id=<?php the_ID(); ?>" class="btn-tour-mail">フォームから問合せる </div><!-- /.btn-tour-contact01 --> </div><!-- /.tour-contact01 --> <section id="tour-access"> <div class="wrap-tour-access"> <h3 class="mincho title-border">開催日時・アクセス</h3> <p>※完全予約制となります。お電話または予約フォームよりご予約ください。</p> <div class="tour-detail"> <?php if(get_field('k-date')) :?> <dl><dt>開催日</dt><dd><?php the_field('k-date'); ?></dd></dl> <?php endif; ?> <?php if(get_field('k-time')) :?> <dl><dt>時間</dt><dd><?php the_field('k-time'); ?></dd></dl> <?php endif; ?> <?php if(get_field('k-address')) :?> <dl><dt>場所</dt><dd><?php the_field('k-address'); ?></dd></dl> <?php endif; ?> <?php if(get_field('k-place')) :?> <dl><dt>集合場所</dt><dd><?php the_field('k-place'); ?></dd></dl> <?php endif; ?> </div><!-- /.tour-detail --> <?php if(get_field('k-url')) :?> " target="_blank">現在の予約状況はこちら <?php endif; ?> <?php if(get_field('k-covid')) :?> <section class="tour-covid"> <h4 class="mincho">新型コロナウイルスへの対策とお願い</h4> <p>皆様に安心してご見学いただけるように、以下の通りご案内いたします。</p> <section> <h5>会場について</h5> <p>スタッフは手指を消毒の上、マスク着用にてご案内させていただきます。<br /> 同一時間帯に室内が多人数にならない様に、最大3組様の入場とさせていただきます。<br /> 完全予約制となります。お電話または予約フォームよりご予約ください。<br /> 室内は定期的に換気をさせていただきます。</p> </section> <section> <h5>お客様へのお願い</h5> <p>マスク着用でのご来場をお願いいたします。<br /> 受付にて手指のアルコール消毒をお願いいたします。また、通常通り、手袋着用にてご入場をお願いいたします。<br /> (アルコール、手袋は受付にご用意しております)</p> </section> </section><!-- /.tour-covid --> <?php endif; ?> </div><!-- /.wrap-tour-access --> <section class="wrap-tour-contact02"> <div class="tour-contact02"> <h4>完全予約制となります。お電話または予約フォームよりご予約ください。</h4> <div class="tour-contact-box"> " alt="" /> <div class="tour-contact-text"> <p>当日は中学生未満のお子様のご入場をお控え頂いていますが、会場に専属スタッフが常駐するキッズコーナー(空調完備)をご用意しておりますので、お子様連れでもどうぞお気軽に♪ 宮下工務店スタッフ一同、みなさまのご来場をお待ちしています。 他にも気になることや疑問・質問、何でもお気軽にご相談ください。</p> <?php if(get_field('k-url')) :?> " target="_blank">現在の予約状況はこちら <?php endif; ?> </div><!-- /.tour-contact-text --> </div><!-- /.tour-contact-box --> <div class="btn-tour-contact01"> 053-437-2695 /contact/?post_id=<?php the_ID(); ?>" class="btn-tour-mail">フォームから問合せる </div><!-- /.btn-tour-contact01 --> </div><!-- /.tour-contact02 --> </section><!-- /.wrap-tour-contact02 --> </section><!-- /tour-access --> <?php }elseif ( is_singular('news') ) { ?> /contact/?post_id=<?php the_ID(); ?>" class="btn-single-land">この記事について問い合わせる </div><!-- /.wrap-content --> <?php } } ); //datepicker関連 // css読み込み add_action( 'wp_enqueue_scripts', function () { wp_enqueue_style( 'pickadate-default', MY_SNOW_MONKEY_URL . '/assets/pickadate/css/default.css', [ Framework\Helper::get_main_style_handle() ], filemtime( MY_SNOW_MONKEY_PATH . '/assets/pickadate/css/default.css' ), false ); wp_enqueue_style( 'pickadate-default_date', MY_SNOW_MONKEY_URL . '/assets/pickadate/css/default.date.css', [ Framework\Helper::get_main_style_handle() ], filemtime( MY_SNOW_MONKEY_PATH . '/assets/pickadate/css/default.date.css' ), false ); // js読み込み wp_enqueue_script( 'pickadate', MY_SNOW_MONKEY_URL . '/assets/pickadate/js/picker.js', ['jquery'], filemtime( MY_SNOW_MONKEY_PATH . '/assets/pickadate/js/picker.js' ), false, true ); wp_enqueue_script( 'pickadate-date', MY_SNOW_MONKEY_URL . '/assets/pickadate/js/picker.date.js', ['jquery', 'pickadate'], filemtime( MY_SNOW_MONKEY_PATH . '/assets/pickadate/js/picker.date.js' ), false, true ); wp_enqueue_script( 'pickadate-legacy', MY_SNOW_MONKEY_URL . '/assets/pickadate/js/legacy.js', ['jquery', 'pickadate'], filemtime( MY_SNOW_MONKEY_PATH . '/assets/pickadate/js/legacy.js' ), false, true ); wp_enqueue_script( 'pickadate-translate', MY_SNOW_MONKEY_URL . '/assets/pickadate/js/ja_JP.js', ['jquery', 'pickadate'], filemtime( MY_SNOW_MONKEY_PATH . '/assets/pickadate/js/ja_JP.js' ), false, true ); wp_enqueue_script( 'pickadate-origin', MY_SNOW_MONKEY_URL . '/assets/pickadate/js/pickadate.js', ['jquery', 'pickadate'], filemtime( MY_SNOW_MONKEY_PATH . '/assets/pickadate/js/pickadate.js' ), true ); } ); //エントリーフォーム完了ページ遷移 add_action( 'wp_enqueue_scripts', function() { ob_start(); ?> window.addEventListener( 'load', function() { var form = document.getElementById( 'snow-monkey-form-734' ); if (form) { form.addEventListener( 'smf.submit', function(event) { if ('complete' === event.detail.status) { window.location.href = 'https://bsd-service.jp/miyashita/entry/thanks/'; } } ); } } ); <?php $data = ob_get_clean(); wp_add_inline_script( 'snow-monkey-forms', $data, 'after' ); }, 11 ); //お問い合わせ・資料請求完了ページ遷移 add_action( 'wp_enqueue_scripts', function() { ob_start(); ?> window.addEventListener( 'load', function() { var form = document.getElementById( 'snow-monkey-form-512' ); if (form) { form.addEventListener( 'smf.submit', function(event) { if ('complete' === event.detail.status) { window.location.href = 'https://bsd-service.jp/miyashita/contact/thanks/'; } } ); } } ); <?php $data = ob_get_clean(); wp_add_inline_script( 'snow-monkey-forms', $data, 'after' ); }, 11 ); //オープンハウス・見学会予約フォーム完了ページ遷移 add_action( 'wp_enqueue_scripts', function() { ob_start(); ?> window.addEventListener( 'load', function() { var form = document.getElementById( 'snow-monkey-form-1280' ); if (form) { form.addEventListener( 'smf.submit', function(event) { if ('complete' === event.detail.status) { window.location.href = 'https://bsd-service.jp/miyashita/tour-form/thanks/'; } } ); } } ); <?php $data = ob_get_clean(); wp_add_inline_script( 'snow-monkey-forms', $data, 'after' ); }, 11 ); //無料相談フォーム完了ページ遷移 add_action( 'wp_enqueue_scripts', function() { ob_start(); ?> window.addEventListener( 'load', function() { var form = document.getElementById( 'snow-monkey-form-10041' ); if (form) { form.addEventListener( 'smf.submit', function(event) { if ('complete' === event.detail.status) { window.location.href = 'https://bsd-service.jp/miyashita/free-form/thanks/'; } } ); } } ); <?php $data = ob_get_clean(); wp_add_inline_script( 'snow-monkey-forms', $data, 'after' ); }, 11 ); //記事タイトルを取得してフォームに入力 add_filter( 'snow_monkey_forms/control/attributes', function( $attributes ) { if ( isset( $attributes['name'] ) && 'productName' === $attributes['name'] ) { $url = $_SERVER['REQUEST_URI']; if(strstr($url,'?post_id')==true){ // ?post_id という URL クエリがあるときが対象 $post_id = filter_input( INPUT_GET, 'post_id' ); $title = get_the_title( $post_id ); if ( $title ) { $attributes['value'] = $title; } } } return $attributes; } ); //管理画面カスタム投稿一覧でタクソノミー別の表示用セレクト function add_post_taxonomy_restrict_filter() { global $post_type; if ( 'works' == $post_type ) { ?> <select name="workscat"> <option value="">カテゴリー指定なし</option> <?php $terms = get_terms('workscat'); foreach ($terms as $term) { ?> <option value="<?php echo $term->slug; ?>"><?php echo $term->name; ?></option> <?php } ?> </select> <?php } } add_action( 'restrict_manage_posts', 'add_post_taxonomy_restrict_filter' );
    0
    いいねをした人: 居ません
    #115667

    返信が含まれるトピック: 子カテゴリーのラベル表示について

    Rin
    参加者
    1

    下記のコードで解決しました。ありがとうございました。

    add_filter(
    'snow_monkey_get_template_part_args_template-parts/loop/entry-summary/term/term',
    function( $args ) {
    // カテゴリーアーカイブあるいは記事作成者ページあるいはタグ一覧ページのとき
    if ( is_category() || is_author() || is_tag()) {
    // その投稿に割当てられているカテゴリーを全て取得
    $terms = get_the_terms( get_the_ID(), 'category' );
    // 取得したカテゴリー(タクソノミー)のうち、最後のタームをカテゴリーラベルとして使用する
    $args['vars']['_terms'] = [ end( $terms ) ];
    }
    return $args;
    }
    );
    
    1
    いいねをした人:
    #115645

    返信が含まれるトピック: 子カテゴリーのラベル表示について

    キタジマ タカシ
    参加者
    2234

    $terms = get_the_terms( get_the_ID(), 'category' ); というふうに category 固定にしちゃったらどうですかね?

    add_filter(
    	'snow_monkey_get_template_part_args_template-parts/loop/entry-summary/term/term',
    	function( $args ) {
    		// カテゴリーアーカイブあるいはタクソノミーアーカイブのとき
    		if ( is_category() || is_tax() ) {
    			// その投稿に割当てられているカテゴリーを全て取得
    			$terms = get_the_terms( get_the_ID(), 'category' );
    			// 取得したカテゴリー(タクソノミー)のうち、最後のタームをカテゴリーラベルとして使用する
    			$args['vars']['_terms'] = [ end( $terms ) ];
    		}
    		return $args;
    	}
    );
    3
    いいねをした人:
    #115623
    Rin
    参加者

    【お使いの Snow Monkey のバージョン】18.2.0
    【お使いの Snow Monkey Blocks のバージョン】17.2.0
    【お使いの Snow Monkey Editor のバージョン】9.1.0
    【お使いのブラウザ】Chrome

    ### 実現したいこと

    タグで投稿記事を絞り込んだ際に、記事のカテゴリーラベルを、親カテゴリーではなく、子カテゴリーに統一したい。(※複数のライターが記事を執筆するので、親と子の両方のカテゴリー登録があっても、子カテゴリーのみ表示させるよう統一したい)

    ### 発生している問題

    タグで投稿記事を絞り込んだ際に、記事のカテゴリーラベルが、親カテゴリーで表示される。

    ### 試したこと

    下記のコードにより、親カテゴリーで絞り込んだ際は、子カテゴリーのラベルが表示されるようになった。しかしタグで絞り込んだ際は親カテゴリーのラベルのままです。

    add_filter(
    	'snow_monkey_get_template_part_args_template-parts/loop/entry-summary/term/term',
    	function( $args ) {
    		// カテゴリーアーカイブあるいはタクソノミーアーカイブのとき
    		if ( is_category() || is_tax() ) {
    			// ページのクエリ情報を取得
    			$queried_object = get_queried_object();
    			// その投稿に割当てられているカテゴリー(タクソノミー)を全て取得
    			$terms = get_the_terms( get_the_ID(), $queried_object->taxonomy );
    			// 取得したカテゴリー(タクソノミー)のうち、最後のタームをカテゴリーラベルとして使用する
    			$args['vars']['_terms'] = [ end( $terms ) ];
    		}
    		return $args;
    	}
    );

    どうぞよろしくお願いいたします。

    #112373
    GONSY
    参加者
    803
    add_filter(
    	'snow_monkey_get_template_part_args_template-parts/common/page-header',
    	function( $args ) {
    		if ( is_singular( 'post' ) ) {
    			$args['vars']['_title'] = 'NEWS';
    			$args['vars']['_display_entry_meta'] = false;
    		}
    		return $args;
    	}
    );

    こんな感じでしょうか。
    お試しくださいませ。

    2
    いいねをした人:
    #110635
    キタジマ タカシ
    参加者
    2234

    ありがとうございます。試してみたのですが、僕の環境ではそのコードでは年にならず「Works」のままでした。カテゴリーを登録する順番とか、何かが影響するのかもしれません。

    ということで、上記のコードを改変して、下記のコードにして追加してみました。

    add_filter(
    	'snow_monkey_get_template_part_args_template-parts/loop/entry-summary/term/term',
    	function( $args ) {
    		// カテゴリーアーカイブあるいはタクソノミーアーカイブあるいは投稿のとき
    		if ( is_category() || is_tax() || is_singular( 'post' ) ) {
    			// ページのクエリ情報を取得
    			$queried_object = get_queried_object();
    
    			// その投稿に割当てられているカテゴリーを全て取得
    			$_terms = get_the_terms( get_the_ID(), 'category' );
    			if ( ! $_terms ) {
    				return $args;
    			}
    
    			$new_terms = [];
    			// 割当てられているカテゴリーのうち、カテゴリー名が数字4桁のものがあればそれを使う
    			foreach ( $_terms as $_term ) {
    				if ( preg_match( '|^\d{4}$|', $_term->name ) ) {
    					$new_terms[] = $_term;
    					break;
    				}
    			}
    			$args['vars']['_terms'] = $new_terms;
    		}
    		return $args;
    	}
    );
    0
    いいねをした人: 居ません
    #110628
    NAUTICA(ノーチカ)
    参加者
    8

    ありがとうございます。
    北島さんのサンプルコードそのまんまなのですが,my-snow-monkey.phpに以下の通り追加しています。

    /**
     * カテゴリーラベル
     */
    add_filter(
    	'snow_monkey_get_template_part_args_template-parts/loop/entry-summary/term/term',
    	function( $args ) {
    		// カテゴリーアーカイブあるいはタクソノミーアーカイブのとき
    		if ( is_category() || is_tax() ) {
    			// ページのクエリ情報を取得
    			$queried_object = get_queried_object();
    			// その投稿に割当てられているカテゴリー(タクソノミー)を全て取得
    			$terms = get_the_terms( get_the_ID(), $queried_object->taxonomy );
    			// 取得したカテゴリー(タクソノミー)のうち、最後のタームをカテゴリーラベルとして使用する
    			$args['vars']['_terms'] = [ end( $terms ) ];
    		}
    		return $args;
    	}
    );
    0
    いいねをした人: 居ません
    #110531
    NAUTICA(ノーチカ)
    参加者
    8

    ご対応ありがとうございました。
    どのラベルもメインカテゴリーが表示されるようになりました。

    WORKSアーカイブの中は,下記のトピックを参考にフックで年号が表示されるように変更しました。

    ただ,投稿の関連記事のところがテンプレートパーツまではわかったのですが,その先がわかりませんでした。
    ちょっと教えていただけませんでしょうか。

    add_filter(
    	'snow_monkey_get_template_part_args_template-parts/content/related-posts',
    	function( $args ) {
    		//この中
    	}
    );
    0
    いいねをした人: 居ません
15件の結果を表示中 - 16 - 30件目 (全112件中)

ドキュメント

Snow Monkey の設定方法やマニュアルを掲載しています。

ドキュメント

フォーラム

Snow Monkey の使い方やカスタマイズについてのご質問・ご要望等はサポートフォーラムで行っています。サポートフォーラムは誰でも閲覧できますが、書き込みできるのは Snow Monkey 購入者のみとなります。

サポートフォーラム

よくあるご質問

Snow Monkey のサービスについて不明な点がある場合は、まずはよくあるご質問をご確認ください。

よくあるご質問

お問い合わせ

よくあるご質問を見ても解決しなかった場合、試用版の申請については問い合わせフォームからお願いいたします。

お問い合わせ

Snow Monkey は Gutenberg ブロックエディターに対応した 100%GPL の WordPress テーマです。拡張性を意識した開発をおこなっており、カスタマイザーとブロックでスピーディーにサイトを立ち上げるだけでなく、CSS やフックを駆使した高度なカスタマイズにも柔軟に対応できます。