Skip to content

Instantly share code, notes, and snippets.

@gatespace
gatespace / wp_get_theme.php
Last active February 10, 2017 03:07
WordPress のテーマ情報の取得 ref: http://qiita.com/gatespace/items/b6731f156322e44096bd
<?php
$my_theme = wp_get_theme();
// Echo the name of the current active theme.
echo $my_theme; // wp_get_theme()
// Display the Current Theme's Version
echo $my_theme->Name . " is version " . $my_theme->Version;
// Display the Current Theme Author URI
@gatespace
gatespace / ignore_shortcode.php
Last active February 10, 2017 03:08
WordPress の投稿編集画面でコメントアウトを使えるようにする ref: http://qiita.com/gatespace/items/623ae078fff14f20e4ba
<?php
/**
* 投稿内でコメントアウトできるようにする
*/
function ignore_shortcode( $atts, $content = null ) {
return null;
}
add_shortcode( 'ignore', 'ignore_shortcode', '9999' );
@gatespace
gatespace / file0.php
Last active February 10, 2017 03:08
WordPress 検索対象のあれこれ ref: http://qiita.com/gatespace/items/4f4bd4d15fea65885972
<?php
function search_filter($query) {
if ( is_admin() || ! $query->is_main_query() )
return;
if ( $query->is_search() ) {
$query->set( 'category__not_in', array( 1 ) );
return;
}
}
@gatespace
gatespace / comment_form.php
Last active February 10, 2017 03:10
WordPress テーマ _s にFoundation6 を組み込んでみる ref: http://qiita.com/gatespace/items/873887d4d8ba7ac36537
<?php
comment_form( array( 'class_submit' => 'button' ) );
@gatespace
gatespace / bootstrap_comment_form_default_fields.php
Last active February 10, 2017 03:10
WordPress テーマ _s にBootstrap3 を組み込んでみる ref: http://qiita.com/gatespace/items/800d78886258f1a8b00f
<?php
function bootstrap_comment_form_default_fields( $fields ) {
foreach ( $fields as $field => $value ) {
$value = preg_replace(
'/comment-form-([^\"|^\']*)/i',
'comment-form-\1 form-group',
$value
);
.left-double-border {
border-left: solid 6px red;
padding-left: 2px;
}
.left-double-border:before {
content: " ";
border-left: solid 2px red;
margin-right: 10px;
padding: 4px 0;
}
@gatespace
gatespace / file1.html
Last active February 10, 2017 03:11
WordPress ギャラリーショートコードのカスタマイズ(サムネイル+大きい画像+画像が表示されたらGoogleアナリティクスに送信) ref: http://qiita.com/gatespace/items/568a3c601cf762207a87
<div id='gallery-1' class='gallery galleryid-555 gallery-columns-3 gallery-size-thumbnail'>
<div class="gallery-bxslider">
<figure class='slider-item' data-href='/archives/555/canola2'>
<div class='slider-icon landscape'>
<img width="640" height="480" src="http://example.com/wp-content/uploads/2011/01/canola2.jpg" />
</div>
<figcaption class='slider-caption-text slider-caption' id='gallery-1-611'>
caption text.
</figcaption>
</figure>
@gatespace
gatespace / excerpt-length.php
Last active February 10, 2017 03:52
WordPress 抜粋と「続きを読む」のカスタマイズ小ネタ ref: http://qiita.com/gatespace/items/61e40a5bdb30a4f80a83
<?php
/**
* Filter the except length to 20 characters.
*
* @param int $length Excerpt length.
* @return int (Maybe) modified excerpt length.
*/
function wpdocs_custom_excerpt_length( $length ) {
return 20;
}
@gatespace
gatespace / view-all-family-page-link.php
Last active February 10, 2017 03:52
WordPress 表示している固定ページが属する最上位〜全ての子孫ページのリストを表示 ref: http://qiita.com/gatespace/items/0910fef889eb589fd10b
@gatespace
gatespace / my-post-navigation.css
Last active February 10, 2017 03:52
WordPress 投稿の前後記事へのリンクにアイキャッチ画像を使う ref: http://qiita.com/gatespace/items/34b9c71378bbfc20b6f0
.post-navigation .nav-previous a,
.post-navigation .nav-next a {
display: block;
color: white;
background: #353c3f;
background-repeat: no-repeat;
background-position: center center;
background-size: cover;
}
.post-navigation .nav-previous a:hover,