Skip to content

Instantly share code, notes, and snippets.

h1.entry-title {
text-align: left;
font-size: 2.4rem;
}
@media (min-width: 700px) {
h1.entry-title {
font-size: 3.4rem;
}
}
@media (min-width: 1220px) {
@rocket-martue
rocket-martue / [inc_file slug=$slug]
Last active December 26, 2020 08:32
テーマのincディレクトリにあるテンプレートを呼び出すショートコード
add_shortcode( 'inc_file', function ( $atts ) {
extract( shortcode_atts(
array(
'slug' => '',
), $atts ) );
ob_start();
get_template_part( 'inc/'.$slug );
$html = ob_get_contents();
ob_end_clean();
return $html;
@rocket-martue
rocket-martue / [section slug=$slug ]
Last active December 26, 2020 08:38
テーマのsectionディレクトリのファイルを呼び出すショートコード
add_shortcode( 'section', function( $atts ) {
extract( shortcode_atts(
array(
'slug' => '',
), $atts ) );
ob_start();
get_template_part( 'section/'.$slug );
$html = ob_get_contents();
ob_end_clean();
return $html;
@rocket-martue
rocket-martue / Snow Monkey で、フック (snow_monkey_append_main) を使ってページ下部に再利用ブロックを表示する
Last active March 12, 2021 13:50
Snow Monkey で、フック (snow_monkey_append_main) を使ってページ下部に再利用ブロックを表示する。
add_action(
'snow_monkey_append_main',
function() {
$reuse_block = get_post( $id ); // $id は、再利用ブロックのID
echo apply_filters( 'the_content', $reuse_block->post_content );
}
);
add_action( 'admin_menu', function() {
add_menu_page( 'Reusable Blocks', '再利用ブロック', 'edit_posts', 'edit.php?post_type=wp_block', '', 'dashicons-block-default', 22 );
} );
add_action(
'after_setup_theme',
function() {
register_nav_menus(
[
'global-nav-2' => esc_html__( 'Global Navigation 2 (For PC)', 'snow-monkey' ),
'drawer-nav-2' => esc_html__( 'Drawer Navigation 2 (For Mobile)', 'snow-monkey' ),
'global-nav-3' => esc_html__( 'Global Navigation 3 (For PC)', 'snow-monkey' ),
'drawer-nav-3' => esc_html__( 'Drawer Navigation 3 (For Mobile)', 'snow-monkey' ),
]
@rocket-martue
rocket-martue / snow-monkey-taxonomy-posts-fluid-shape-1.css
Created March 16, 2021 01:29
Snow Monkey 任意のタクソノミーの投稿の画像を「画像」ブロックで使用できる流体にする
.snow-monkey-taxonomy-posts .c-entry-summary__figure {
background-color:transparent;
}
.snow-monkey-taxonomy-posts .c-entries__item>a .c-entry-summary__figure>img {
-webkit-mask-repeat: no-repeat;
mask-repeat: no-repeat;
-webkit-mask-position: 50% 50%;
mask-position: 50% 50%;
-webkit-mask-size: contain;
@rocket-martue
rocket-martue / calling-reusable-block-by-slug-and-displaying-in-footer.php
Last active October 11, 2021 08:17
再利用ブロックを slug で呼び出してフッターに表示する。(snow_monkey_prepend_footer)
@rocket-martue
rocket-martue / custom-header-position.php
Last active October 11, 2021 08:10
Snow Monkey のヘッダー位置をカスタマイズする
<?php
add_filter(
// PC 用ヘッダー位置をカスタマイズ
'theme_mod_header-position-lg',
function( $value ) {
// フロントページならば
if ( is_front_page() ) {
// オーバーレイ(上部固定 / スクロール時背景白)
return 'sticky-overlay-colored';
}
@rocket-martue
rocket-martue / add_shoetcode-reusable-block.php
Last active October 11, 2021 08:06
再利用ブロックをスラッグで表示するショートコード
<?php
// [reusable slug=$slug]
add_shortcode(
'reusable',
function ( $atts ) {
extract( shortcode_atts(
array(
'slug' => '',
), $atts ) );
ob_start();