Skip to content

Instantly share code, notes, and snippets.

View cazuki's full-sized avatar

Cazuki Hoshina cazuki

View GitHub Profile
@cazuki
cazuki / wp-functions-rss-contents-insert.php
Last active August 29, 2015 14:25
WordPressのRSSに署名などのコンテンツを追加
// フィードにコンテンツを追加
function do_post_contents_feeds($content) {
global $post;
if(has_post_thumbnail($post->ID)) {
$content = '<div>' .get_the_post_thumbnail($post->ID). '</div>' .$content. '<div><a href="' .get_permalink($post->ID).'" target="_blank">この記事の続きを読む</a></div><div><a href="' .get_permalink($post->ID). '" target="_blank">' .get_the_title($post->ID). '</a> は <a href="http://example.jp/" target="_blank">ブログタイトル</a> の記事です</div>';
}
return $content;
}
add_filter('the_excerpt_rss', 'do_post_contents_feeds');
add_filter('the_content_feed', 'do_post_contents_feeds');
@cazuki
cazuki / facebook-original-send-button.html
Created July 17, 2015 12:02
Facebookの「Send Button」を独自実装するコード
<a href="http://www.facebook.com/dialog/send
?app_id=12345678
&link=http://mbdb.jp/hacks/facebook-original-send-button.html
&redirect_uri=http://mbdb.jp/">送る</a>
@cazuki
cazuki / wordpress-post_class.php
Created July 17, 2015 12:07
WordPressにおけるpost_class関数の実装
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>></article>
@cazuki
cazuki / wp-hentry-remove.php
Created July 17, 2015 12:09
WordPressでhentryを削除する記述
function remove_hentry( $classes ) {
$classes = array_diff($classes, array('hentry'));
return $classes;
}
add_filter('post_class', 'remove_hentry');
@cazuki
cazuki / mbdb-robots.txt
Created July 29, 2015 07:38
モバデビのrobots.txtファイルの記述内容です。
User-agent: *
Disallow: /wp-admin
Disallow: /wp-includes
Allow: /wp-content/uploads
Allow: /wp-includes/js
Disallow: /*?*
Disallow: /*?
Disallow: /*.php$
Disallow: /*.js$
Disallow: /*.inc$
@cazuki
cazuki / wp-del-category-base.php
Last active August 29, 2015 14:27
WordPressのカテゴリーベースを置換して削除
function catbase_function($link) {
return str_replace("/category/", "/", $link);
}
function catbase_flush_rules() {
global $wp_rewrite;
$wp_rewrite->flush_rules();
}
function catbase_rewrite($wp_rewrite) {
$new_rules = array('(.+)/page/(.+)/?' => 'index.php?category_name='.$wp_rewrite->preg_index(1).'&paged='.$wp_rewrite->preg_index(2));
$wp_rewrite->rules = $new_rules + $wp_rewrite->rules;
@cazuki
cazuki / balloon-chat-contents.php
Created August 16, 2015 15:51
WordPressでチャット風会話形式コンテンツを表示する
<?php
function balloon_shortcode($atts, $content = null) {
extract(shortcode_atts(array(
'face' => '1',
'name' => '自分の名前',
'align' => 'right'
),$atts));
switch ($face) {
case 1:
$imageUrl = get_stylesheet_directory_uri().'/テーマフォルダ内の画像までのパス';
@cazuki
cazuki / balloon-chat-contents.css
Created August 16, 2015 16:14
WordPressでチャット風会話形式のコンテンツを表示するためのCSS
.balloon-box {
overflow: hidden;
margin: 0 0 0.8rem;
}
.balloon-box:last-of-type {
margin: 0 0 1.7rem;
}
.balloon-icon {
width: 90px;
text-align: center;
@cazuki
cazuki / totalsharecount-random-post.php
Last active September 2, 2015 05:26
SNS Count Cacheのトータルシェア数を使って人気の記事をランダム表示する
<ul>
<?php
$featured = get_posts( array (
'meta_query' => array (array(
'key' => 'scc_share_count_total',
'value' => '200',
'compare' => '>=',
'type' => 'NUMERIC'
)),
'post_status' => 'publish',
@cazuki
cazuki / https-redirect.txt
Created September 17, 2015 05:52
HTTPSへの301リダイレクト
RewriteEngine on
RewriteCond %{SERVER_PORT} !^443$ [OR]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://www.domain.com/$1 [R=301,L]