Skip to content

Instantly share code, notes, and snippets.

@ma2i
ma2i / .htaccess
Last active September 20, 2019 02:17
【WordPress】wp-config.php へのアクセスを制限
<files wp-config.php>
order allow,deny
deny from all
</files>
@ma2i
ma2i / RetinaDisplay.scss
Created September 20, 2019 02:16
RetinaDisplay.scss
@media
only screen and ( -webkit-min-device-pixel-ratio: 2 ),
only screen and ( min-resolution: 2dppx) {
background : url(/ja/img/sample@2x.png) left top;
background-repeat : no-repeat;
background-size : cover;
}
@ma2i
ma2i / .htaccess
Created September 20, 2019 02:18
wwwあり、httpsに統一
# wwwあり、httpsに統一
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^sensei\.biz
RewriteRule (.*) http://www.sensei.biz/$1 [R=301,L]
RewriteCond %{HTTPS} !on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</IfModule>
@ma2i
ma2i / .htaccess
Created September 20, 2019 02:19
httpsに統一
# httpsに統一
RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
@ma2i
ma2i / .htaccess
Created September 20, 2019 02:20
クロスドメイン対策(RSSを取得される側=Blogの.htaccessに設定)
Header set Access-Control-Allow-Origin *
@ma2i
ma2i / functions.php
Created September 20, 2019 02:20
【WordPress】子テーマに設置したカスタマイズしたRSSを優先する設定
/* RSSは、子テーマに設置した「feed-rss2.php」を優先する設定 */
remove_filter('do_feed_rss2', 'do_feed_rss2', 10);
function custom_feed_rss2(){
$template_file = '/feed-rss2.php';
load_template(get_stylesheet_directory() . $template_file);
}
add_action('do_feed_rss2', 'custom_feed_rss2', 10);
@ma2i
ma2i / functions.php
Created September 20, 2019 02:22
【WordPress】見出しを画面上部に固定表示する方法
/*
① プラグイン「Easy Table of Contents」 は入れておく
② ページのスクロールと連動し、今読んでいるコンテンツの見出しが画面上部に固定表示される
*/
//上部固定の見出しラベルを作るよ
function kjk_fixed_headline_script() {
?>
@ma2i
ma2i / bootstrap-flexbox.css
Created September 20, 2019 02:23
Bootstrap(FlexBox)一部
/* Flex */
.d-flex{
display : flex;
}
.d-inline-flex{
display : inline-flex;
}
/* Direction */
.flex-row{
@ma2i
ma2i / functions.php
Created September 20, 2019 02:24
【WordPress】特定カテゴリの記事をブログトップの新着記事一覧で表示させない
/* 特定のカテゴリの除外
function exclude_category( $query ) {
if ( $query->is_home() && $query->is_main_query() ) {
$query->set( 'cat', '-8,-9' );//マイナスをつけてカテゴリIDを除外する
}
}
add_action( 'pre_get_posts', 'exclude_category' );
@ma2i
ma2i / Bootstrap-Responsive-Breakpoints.css
Created September 20, 2019 02:25
レスポンシブ対応(Bootstrap4のブレークポイント)
// Small devices (landscape phones, 576px and up)
@media (min-width: 576px) { ... }
// Medium devices (tablets, 768px and up)
@media (min-width: 768px) { ... }
// Large devices (desktops, 992px and up)
@media (min-width: 992px) { ... }
// Extra large devices (large desktops, 1200px and up)