「entry-summary $html」の検索結果

15件の結果を表示中 - 31 - 45件目 (全77件中)
  • 投稿者
    検索結果
  • アバター画像yuu
    閲覧者
    28

    オレインさんの記事を読みながら色々とやってみたらできそうです。
    確認していただけますか?

    ただ、抜粋の長さに関わらずリンクボタンを右寄せにしたいのですが、イマイチできません。
    そこだけお聞きしてもいいでしょうか?

    my-snow-monkey.php

    add_filter(
    	'snow_monkey_template_part_render_template-parts/loop/entry-summary/content/content',
    	function ( $html ) {
    		$acf_link = get_field( 'link' );
    
    		$acf_reserve_link = "<div class="c-entry-summary__content">
    <div class="reserve-link"><a class="reserve-btn" href="$acf_link" target="_blank" rel="noopener">チケット予約</a>";
    
    		$html = str_replace(
    			'<div class="c-entry-summary__content">',
    			$acf_reserve_link,
    			$html
    		);
    		return $html;
    	}
    );

    css

    .reserve-link {
      display:flex;
      flex-direction:row-reverse;
      justify-content:space-between;
    }
    .reserve-btn {
      border: 1px solid #000;
      padding:10px 50px;
      border-radius: 10px;
    }
    .reserve-link a {
      text-decoration:none;
      color: #000;
    }
    0
    いいねをした人: 居ません
    #89230
    diiih
    参加者
    18

    ありがとうございます。

    いただいたコードですが下記のようにするということでしょうか。これではカスタムフィールドも表示されませんでした。使い方が間違っていますでしょうか。

    add_action(
    'snow_monkey_get_template_part_template-parts/loop/entry-summary/content/content-{contract}',
    function( $html ) {
    if (get_post_type() === 'contract'): //カスタム投稿contractに限定する
    // 以降の出力を変数に格納する
    ob_start();
    ?>
    <div class="contract-data">
    <p>表示1:<?php echo esc_html (get_field('type')); ?></p>
    <p>表示2:<?php echo esc_html (get_field('station')); ?></p>
    <p>表示3:<?php echo esc_html (get_field('time')); ?></p>
    </div>
    <?php
    // 変数に格納する
    $type = ob_get_clean();
    // </header>を書き換える
    return str_replace(
    '</header>',
    '</header>'.$type,
    $html
    );
    endif;
    return $html;
    }
    );
    0
    いいねをした人: 居ません
    #87131
    林淳一
    参加者
    25

    以下を参考にしました。

    add_filter(
    	'snow_monkey_template_part_render',
    	function( $html, $slug ) {
    		if ( 'template-parts/loop/entry-summary/meta/meta' === $slug ) {
    			return preg_replace(
    '|
    <ul>
     	<li class="c-meta__item c-meta__item--published">.*?</li>
    </ul>
    |ms',
    '
    <ul>
     	<li class="c-meta__item c-meta__item--modified">' . get_the_modified_time( get_option( 'date_format' ) ) . '</li>
    </ul>
    ',
    				$html
    			);
    		}
    		return $html;
    	},
    	10,
    	2
    );
    0
    いいねをした人: 居ません
    GONSY
    参加者
    846

    shiさん

    くわしくありがとうございます。
    概ね以下のコードをmy-snow-monkey.phpに追加していただければ、ご希望の表示はできると思います。(もっと良いコードの書き方はあると思いますので参考までに(^^;)

    使用しているget_field()の部分は、設定しているフィールド名に変更してください。
    また不要なものは消してください。

    add_filter(
    'snow_monkey_template_part_render_template-parts/loop/entry-summary',
    	function( $html ) {
    	if ( 'event' === get_post_type() ):
    	ob_start();
    	?>
    	<?php
    
    		// カスタムフィールド:開催日 → event_day
    		// ACF デイトピッカー(返り値:Ymd)
    		$eDate =  get_post_meta( get_the_ID(), 'event_day', true );
    		$date = date_create( $eDate );
    
    		// 曜日用
    		$week = array("日", "月", "火", "水", "木", "金", "土");
    
    		// 開催日の表示は 「月.日」に変更
    		$eventDay = date_format($date,'n.j');
    
    		$today = wp_date('Ymd');
    
    		// カスタムフィールド:開始時刻 → event_starttime
    		// ACF Time Picker(返り値:G:i)
    		$startTime = get_field( 'event_starttime' );
    
    		// カスタムフィールド:開始時刻 → event_endtime
    		// ACF Time Picker(返り値:G:i)
    		$endTime = get_field( 'event_endtime' );
    
    		// 開催日以降の判定
    		// 開催日よりも今日の日付が大きい場合
    		$preriod = strtotime($eDate) < strtotime($today);
    
    		// カスタムフィールド:概要欄 → event_txt
    		// ACF テキストエリア(改行:なにもしない)
    		$eventSummary = get_field( 'event_txt' )
    	?>
    
    	<div class="event_day_post">
    		<p class="event_date"><?php echo esc_attr( $eventDay) ; ?><span class="week"><?php echo esc_attr( $week[(int)date_format($date,'w')] ) ?></span></p>
    		<p class="event_time"><?php echo esc_attr( $startTime ) ; ?> - <?php echo esc_attr( $endTime ) ; ?></p>
    	</div>
    
    	<div class="event_txt">
    		<p><?php echo nl2br( esc_attr( $eventSummary ) ); ?></p>
    	</div>
    
    	<?php if( $preriod ): ?> // 開催日以降の条件分岐
    		<div class="event_finish">終了しました</div>
    	<?php else: ?>
    		<div class="event_open">これから開催です</div>
    	<?php endif; ?>
    
    	<?php
    	$event = ob_get_clean();
    	
    	return str_replace(
    	'</header>',
    	'</header>'.$event , // 投稿タイトルの下に追加
    	
    	$html
    	);
    	endif;
    	return $html;
    	}
    );

    結果 ↓

    4
    いいねをした人:
    #85240
    GONSY
    参加者
    846

    市岡歩夢さん、こんにちは。

    ほかにも方法はあるかと思いますが、こちらでご希望のことができると思います。

    カスタム投稿タイプ名はmember
    Advanced Custom Fieldsのカスタムフィールド(設定)は

    • カスタムフィールド名:spec
    • フィールドタイプ:テキストエリア
    • 改行:なにもしない

    投稿画面でのカスタムフィールドの入力は

    選手経歴______________
    出身地_________________
    ポジション___________
    一言____________

    と、改行しています。
    これらを前提として、my-snow-monkey.phpに以下を追記

    /**
     * 【最近の投稿】(シンプル)投稿タイプ「メンバー」のみカスタムフィールド"spec"を表示
     */
    add_filter(
    	'snow_monkey_template_part_render_template-parts/loop/entry-summary/content/content',
    	function ( $html ) {
    		if ( 'post' == $post_type ) {
    			return $html;
    		}
    		
    		if ( 'member' == get_post_type() ) {
    			return sprintf(
    				'<div class="c-entry-summary__content">%1$s</div>',
    				nl2br( esc_html( get_field( 'spec' ) ) )
    			);
    		}
    		return $html;
    	},
    	10,
    	4
    );
    
    /**
     * CPT"member"のシングルページにカスタムフィールド"spec"を表示
     */
    add_action(
    	'snow_monkey_prepend_entry_content',
    	function() {
    		if ( is_single() && 'member' === get_post_type() ) {
    		?>
    			<div class="member_spec">
    				<p><?php echo nl2br( esc_html( get_field( 'spec' ) ) ); ?></p>
    			</div>
    		<?php
    		}
    	}
    );

    これでどうでしょうか?
    お試しください。

    5
    いいねをした人:

    【お使いの Snow Monkey のバージョン】バージョン: 15.3.5
    【お使いの Snow Monkey Blocks のバージョン】12.1.0
    【お使いの Snow Monkey Editor のバージョン】6.0.0
    【お使いのブラウザ】Chrome
    【当該サイトのURL】 ローカル

    以下の記事を参考にし、一覧ページにカスタムフィールドを反映させる設定を進めております。

    記事内のコードにて、投稿文(c-entry-summary__content)を単一のカスタムフィールドで置き換えることはできましたが、
    この投稿文を複数のカスタムフィールドで置き換える方法はありますでしょうか。
    以上、ご教示のほど宜しくお願い致します。

    add_filter(
    ‘snow_monkey_template_part_render’,
    function( $html, $slug, $name, $vars ) {
    if ( ‘投稿タイプ名’ !== get_post_type() ) {
    return $html;
    }

    if ( ‘template-parts/loop/entry-summary/content/content’ === $slug ) {
    return sprintf(
    ‘<div class=”c-entry-summary__content”>%1$s</div>’,
    esc_html( get_post_meta( get_the_ID(), ‘カスタムフィールド名A’, true ) )
    );
    }

    return $html;
    },
    10,
    4

    まーちゅう
    参加者
    382

    名前と得意分野で、それぞれコードを分けて以下のような感じでどうでしょうか?

    
    /**
     * カスタム投稿タイプのアーカイブページにて、投稿一覧(リッチメディア型)のタイトルの前に、'名前:'を表示
     *
     * @param string $html はコンテンツの中身.
     */
    add_filter(
    	'snow_monkey_template_part_render_template-parts/loop/entry-summary/title/title',
    	function ( $html ) {
    		if ( 'banso-mate' !== get_post_type() ) {
    			return $html;
    		}
    		$html = str_replace( '<h3>', '<h3>名前:', $html );
    		return $html;
    	}
    );
    
    /**
     * カスタム投稿タイプのアーカイブページにて、投稿一覧(リッチメディア型)に、タグ・ディスクリプションを表示
     *
     * @param string $html はコンテンツの中身.
     */
    add_filter(
    	'snow_monkey_template_part_render_template-parts/loop/entry-summary/content/content',
    	function ( $html ) {
    		if ( 'banso-mate' !== get_post_type() ) {
    			return $html;
    		}
    		$postid     = get_the_ID();
    		$taxonomy   = 'banso_tags';
    		$post_terms = get_the_terms( $postid, $taxonomy );
    		if ( ! empty( $post_terms ) ) {
    			$tags = '<div>';
    			$tags .= '<h3>得意分野:</h3>';
    			$tags .= '<div>';
    			$tags .= '<ul class="smb-taxonomy-terms__list">';
    			foreach ( $post_terms as $post_term ) {
    				$term_name = $post_term->name;
    				$tags .= '<li class="smb-taxonomy-terms__item">' . $term_name . '</li>';
    			}
    			$tags .= '</div>';
    			$tags .= '</div>';
    		}
    
    		$meta_description = get_post_meta( get_the_ID(), 'wp-seo-meta-description', true );
    		$html = $tags . '<div class="c-entry-summary__content">' .$meta_description. '</div>';
    		return $html;
    	}
    );
    4
    いいねをした人:
    #80090
    まーちゅう
    参加者
    382

    ありがとうございます。
    get_post_type() に変更で、うまくいきました。

    /**
     * 各投稿一覧で taxonomy のラベルをタイトルの上に表示
     *
     * @param string $html はコンテンツの中身.
     */
    add_filter(
    	'snow_monkey_template_part_render_template-parts/loop/entry-summary/title/title',
    	function ( $html ) {
    		$taxonomy  = 'category';
    		$post_type = get_post_type();
    		switch ( $post_type ) {
    			case 'post':
    				$taxonomy = 'category';
    				break;
    			case 'news':
    				$taxonomy = 'news_category';
    				break;
    			case 'shop-info':
    				$taxonomy = 'shop_genre';
    				break;
    			case 'interview':
    				$taxonomy = '';
    				break;
    		}
    		$tags       = '';
    		$postid     = get_the_ID();
    		$post_terms = get_the_terms( $postid, $taxonomy );
    		if ( ! empty( $post_terms ) ) {
    			$tags = '<ul class="' .$taxonomy. '-tags taxonomy-tags">';
    			foreach ( $post_terms as $post_term ) {
    				$term_name = $post_term->name;
    				$slug      = $post_term->slug;
    				$term_id   = $post_term->term_id;
    				$tags .= '<li class="' .$taxonomy. '-' .$term_id.' ' .$slug.'">' . $term_name . '</li>';
    			}
    			$tags .= '</ul>';
    		}
    		$html       = str_replace( '<h3', $tags . '<h3', $html );
    		return $html;
    	}
    );
    4
    いいねをした人:
    GONSY
    参加者
    846

    ひとまず簡単な方法として、画像を表示しているattachment.phpをiframeをポップアップさせる方法です。

    Easy Fancyboxプラグインを使用している場合になりますが、左メニュー【設定】内の【メディア】を開くと、下部にEasy Fancyboxの各種設定項目がありますので、iFrameにもチェックを入れ【変更を保存】を押してください。

    次に前回ご提示したコード

    <a target="_blank" rel="noreferrer noopener"<a class="fancybox-iframe"に(以下のように)変更します。

    my-snow-monkey.phpに記述

    add_filter(
    	'snow_monkey_template_part_render_template-parts/loop/entry-summary',
    	function( $html ) {
    		if ( is_search() ) {
    			$html = str_replace(
    				'<a',
    				'<a class="fancybox-iframe"',
    			$html
    			);
    		}
    		return $html;
    	}
    );

    これで、検索結果ページの投稿をクリックすると、新しいタブで開くのではなく、ポップアップ(Fancybox)で開くようになると思います。
    一度お試しください。

    3
    いいねをした人:
    i
    参加者
    14

    お世話になります。
    以下のように、追記したら別タブ表示になりました。
    ありがとうございます。

    
    add_filter(
    	'snow_monkey_template_part_render_template-parts/loop/entry-summary',
    	function( $html ) {
    		if ( is_search() ) { // 検索結果ページのみ
    // 			$html = str_replace(
    // 	'<a',
    // 	'<a class="fancybox image"',
    			$html = str_replace(
    				'<a',
    				'<a target="_blank" rel="noreferrer noopener"',
    			$html
    			);
    		}
    		return $html;
    	}
    );
    1
    いいねをした人:
    GONSY
    参加者
    846

    お試しいただけるようで良かったです。
    snow_monkey_template_part_renderは、

    こちらや

    こちら

    で解説されているように、テンプレート内容を書き換えることのできるフィルターフックです。

    snow_monkey_template_part_render_以降のtemplate-parts/loop/entry-summaryは、下に記載したとおり、テーマ内の特定のテンプレートファイル(今回はentry-summary.php)を指しています。

    テーマ「Snow Monkey」

    snow-monkey
    └template-parts
     └loop
      └entry-summary.php

    このentry-summary.php<a href="<?php the_permalink(); ?>">に、target="_blank" rel="noreferrer noopener"を追加する方法になります。

    また、ご質問の見出し

    サイト内検索の検索フォームの画像で検索されたものをクリックした時別タブで表示

    とのことでしたので、検索結果ページ(is_search())にのみ作用するようにします。
    例えば、この検索結果ページ

    以下のコードをmy-snow-monkey.phpに追記することで、お望みの動作になるとは思います。
    ただ、提示しておいて言うのも無責任ですが、適切なコードでないかもしれませんので、ご理解いただいたうえでお試しください。

    add_filter(
    	'snow_monkey_template_part_render_template-parts/loop/entry-summary',
    	function( $html ) {
    		if ( is_search() ) { // 検索結果ページのみ
    			$html = str_replace(
    				'<a',
    				'<a target="_blank" rel="noreferrer noopener"',
    			$html
    			);
    		}
    		return $html;
    	}
    );

    なお、ほかのページにある画像の拡大は、ソースコードを拝見したところ、Easy FancyBoxプラグインによるポップアップ形式になっているようなので、同じ動作をさせる場合には、上記コードの該当箇所を

    $html = str_replace(
    	'<a',
    	'<a class="fancybox image"',

    としてあげると同じ表現になるような気がします。
    ※こちらは未検証です。

    以上となりますが、まずは一度お試しください。

    3
    いいねをした人:
    #78882
    アバター画像キタジマ タカシ
    参加者
    2560

    あ、そうか失礼しました。追加したコードで強制的に更新日が追加されるからですね。

    add_filter(
    	'snow_monkey_template_part_render_template-parts/loop/entry-summary/meta/meta',
    	function( $html ) {
    		// 更新日と公開日が同じ、あるいは更新日より公開日が新しい場合は更新日を追加しない
    		if ( get_the_time( 'Ymd' ) >= get_the_modified_time( 'Ymd' ) ) {
    			return $html;
    		}
    
    		ob_start();
    		?>
    		<li class="c-meta__item c-meta__item--modified">
    			<i class="fas fa-sync-alt" aria-hidden="true"></i>
    				<?php
    				$date_format = get_option( 'date_format' );
    				the_modified_time( $date_format );
    				?>
    			</li>
    		<?php
    		$modified = ob_get_clean();
    		return preg_replace(
    			'|(<li class="c-meta__item c-meta__item--published">.*?</li>)|ms',
    			'$1' . $modified,
    			$html
    		);
    	}
    );
    1
    いいねをした人:
    #78800
    のぶやん
    閲覧者
    22

    キタジマさん、

    該当部分を教えていただいたコードに変えて、My Snow Monkeyに追記して無事出来ました、ありがとうございました。

    add_filter(
    	'snow_monkey_template_part_render_template-parts/loop/entry-summary/meta/meta',
    	function( $html ) {
    		ob_start();
    		?>
    		<li class="c-meta__item c-meta__item--modified">
    			<i class="fas fa-sync-alt" aria-hidden="true"></i>
    				<?php
    				$date_format = get_option( 'date_format' );
    				the_modified_time( $date_format );
    				?>
    			</li>
    		<?php
    		$modified = ob_get_clean();
    		return preg_replace(
    			'|(<li class="c-meta__item c-meta__item--published">.*?</li>)|ms',
    			'$1' . $modified,
    			$html
    		);
    	}
    );

    投稿日と更新日を切り分けて表示させるルールがないので、記事更新をしていないくても強制的に更新日が表示されるので、その点理解して使用してみます。

    0
    いいねをした人: 居ません
    #75670
    Sayoko Miura
    参加者
    6

    functions.phpで、以下のリンクを外す記述をしているだけですね。

    add_filter(
    	'snow_monkey_template_part_render',
    	function( $html, $slug, $name ) {
    		if ( 'template-parts/loop/entry-summary' === $slug && 'tournament_all' === $name ) {
    			$html = preg_replace( '|<a>]+?>|ms', '', $html );
    			$html = str_replace( '|</a>', '', $html );
    			return $html;
    		}
    		return $html;
    	},
    	10,
    	3
    );
    0
    いいねをした人: 居ません
    アバター画像キタジマ タカシ
    参加者
    2560

    改めて確認してみました。当初の

    add_filter(
    	'snow_monkey_template_part_render_template-parts/loop/entry-summary/meta/meta',
    	function( $html ) {
    		ob_start();
    		?>
    		<li class="c-meta__item c-meta__item--comments__number"><span>
    			<?php
    			echo get_comments_number();
    			?>
    		</span>コメント</li>
    		<?php
    		$modified = ob_get_clean();
    		return preg_replace(
    				'|(<li class="c-meta__item c-meta__item--published">.*?</li>)|ms',
    				'$1' . $modified,
    				$html
    		);
    	}
    );

    で正しいと思います。

    0
    いいねをした人: 居ません
15件の結果を表示中 - 31 - 45件目 (全77件中)

ドキュメント

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

ドキュメント

フォーラム

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

サポートフォーラム

よくあるご質問

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

よくあるご質問

お問い合わせ

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

お問い合わせ

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