Skip to content

Instantly share code, notes, and snippets.

@furahaclothing
furahaclothing / gist:3313127
Created August 10, 2012 09:59
ドロップダウンメニュー
/*html*/
<ul id="nav2" class="clearfloat">
<li><a href="<?php echo get_option('home'); ?>/" class="on">Home</a></li>
<?php wp_list_categories('orderby=name&exlude=181&title_li=');
$this_category = get_category($cat);
if (get_category_children($this_category->cat_ID) != "") {
echo "<ul>";
wp_list_categories('orderby=id&show_count=0&title_li=&use_desc_for_title=1&child_of='.$this_category->cat_ID);
echo "</ul>";
}
@furahaclothing
furahaclothing / wpfp-page-template
Created January 29, 2014 09:10
WP favorite post テンプレート
<div class="entry-text"><?php wpfp_clear_list_link(); ?></div>
<?php $favorite_post_ids = wpfp_get_user_meta() ?>
<?php if ($favorite_post_ids):
$favorite_post_ids = array_reverse($favorite_post_ids);
$post_per_page = 20;
$page = intval(get_query_var('paged'));
query_posts(array('post__in' => $favorite_post_ids, 'posts_per_page'=> $post_per_page, 'orderby' => 'post__in', 'paged' => $page)); ?>
<div id="fave_posts_thumbnails">
<?php while ( have_posts() ) : the_post(); ?>
<div class="thumb-gallery"><a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( the_title_attribute() ); ?>"><?php usces_the_itemImage($number = 0, $width = 150, $height = 150 ); ?></a></a><br><div class="remove-link"><?php wpfp_remove_favorite_link(get_the_ID());?></div></div>
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
//上記を変更
<div id="post">
@furahaclothing
furahaclothing / gist:8574421
Created January 23, 2014 07:29
post_class()からhentryクラスを抜く(構造化データ)
function remove_hentry( $classes ) {
$classes = array_diff($classes, array('hentry'));
return $classes;
}
add_filter('post_class', 'remove_hentry');
@furahaclothing
furahaclothing / gist:8574355
Created January 23, 2014 07:22
構造化データリッチスニペット for wordpress
<-- Fixing Warning: Missing required field “entry-title”-->
<h1 class="entry-title"><?php the_title(); ?></h1>
<-- Fixing Warning: Missing required field “updated” -->
<span class="date updated"><?php the_time(); ?></span>
<-- Fixing Warning: Missing required hCard “author” -->
<span class="vcard author">
<span class="fn"><?php the_author(); ?></span>
</span>
@furahaclothing
furahaclothing / jquery.countdown.css
Last active December 31, 2015 03:19
jQuery'countdown'プラグインをwordpressで使う 2013.12.31.23:59:59までカウント。過ぎると、HAPPY NEW YEARのテキスト
<?php
wp_deregister_script('jquery');
wp_enqueue_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js', array(), '1.7.1');
?>
<?php wp_enqueue_script('countdown',get_bloginfo('template_url') . '/countdown/jquery.countdown.js', array('jquery'), '1.0'); ?>
<?php wp_enqueue_script('countdown',get_bloginfo('template_url') . '/countdown/jquery.countdown-ja.js', array('jquery'), '1.0'); ?>
<?php wp_enqueue_style('countdown',get_bloginfo('template_url') . '/countdown/jquery.countdown.css'); ?>
<?php wp_head(); ?>
<script type="text/javascript">
jQuery(function() {
@furahaclothing
furahaclothing / index.php
Created December 9, 2013 05:14
facebook APP(いいね限定ページ)の作成
<?php
include 'signed_request.php';
if (isset($_POST['signed_request']) ) {
$fb_data = parse_signed_request($_POST['signed_request'], 'シークレットキー');
if ($fb_data) {
if( $fb_data['page']['liked'] ){
include 'fan.php';
}
else {
include 'not-fan.php';
@furahaclothing
furahaclothing / gist:7806979
Created December 5, 2013 15:14
welcart デフォルトテンプレート archive.php
<?php
get_header();
?>
<div id="content" class="two-column">
<?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?>
<?php /* If this is a category archive */ if (is_category()) { ?>
<h1 class="pagetitle"><?php printf( __( 'Category Archives: %s', 'uscestheme' ), '<span>' . single_cat_title( '', false ) . '</span>' ); ?></h1>
<?php /* If this is a tag archive */ } elseif( is_tag() ) { ?>
@furahaclothing
furahaclothing / gist:7800218
Last active December 30, 2015 08:08
welcart商品のソート(並び替え) 新着・ランダム・価格(カスタムフィールド名:price)
<form name="irekae" method="get" id="sort_form5" class="sort_form5">
<select name='narabi' onChange="document.forms['irekae'].submit()" >
<option value="sort1"<?php if(!isset($_REQUEST['narabi']) || $_REQUEST['narabi'] == 'sort1') echo ' selected="selected"';?>>新しい順</option>
<option value="sort2"<?php if(isset($_REQUEST['narabi']) && $_REQUEST['narabi'] == 'sort2') echo ' selected="selected"';?>>古い順</option>
<option value="sort3"<?php if(isset($_REQUEST['narabi']) && $_REQUEST['narabi'] == 'sort3') echo ' selected="selected"';?>>価格:安い順</option>
<option value="sort4"<?php if(isset($_REQUEST['narabi']) && $_REQUEST['narabi'] == 'sort4') echo ' selected="selected"';?>>価格:高い順</option>
<option value="sort5"<?php if(isset($_REQUEST['narabi']) && $_REQUEST['narabi'] == 'sort5') echo ' selected="selected"';?>>ランダム</option>
<option value="sort6"<?php if(isset($_REQUEST['narabi']) && $_REQUEST['narabi'] == 'sort6') echo ' selected="selected"';
@furahaclothing
furahaclothing / gist:7512646
Last active December 28, 2015 14:09
wordpressでカテゴリー一覧ページでループ出力(タイトル・サムネイル・カテゴリーリンク)
<?php
global $post;
$tmp_post = $post;
$category_ids = array( '29','33','34','85','113','32','28','43','30','31','114');//カテゴリーID
$numberposts = '4';//投稿数
foreach ( $category_ids as $category_id ) {
?>
/*カテゴリー名*/
<?php echo get_cat_name( $category_id ); ?>
<span class="sub"><a href="<?php echo get_category_link( $category_id ); ?>"><?php _e('see all', 'usces'); ?> &raquo;</a></span>