Skip to content

Instantly share code, notes, and snippets.

@marushu
marushu / posts_numbering.php
Last active September 29, 2015 08:40
投稿ナンバリング
<?php
function sequential_posts_numberting( $post_type = 'post', $posts_per_page = -1, $post_status = 'publish' ) {
$posts_keys = array();
$args = array(
'post_type' => $post_type,
'posts_per_page' => $posts_per_page,
'post_status' => $post_status,
);
$sequential_posts = get_posts( $args );
if( ! empty( $sequential_posts ) ) {
<?
/**
* add custom fields to search query :)
*/
/**
* Extend WordPress search to include custom fields
*
* http://adambalee.com
*/
<?php
$args = array(
'post_type' => 'news',
'posts_per_page' => -1,
);
$set_all_news_posts = get_posts( $args );
foreach( $set_all_news_posts as $post ) {
setup_postdata( $post );
<?php
$args = array(
'post_type' => 'works',
'posts_per_page' => -1,
);
$set_tax_posts = get_posts( $args );
foreach( $set_tax_posts as $post ) {
setup_postdata( $post );
$post_id = $post->ID;
// ここにメディアカスタムタクソノミーを
<?php
/**
* スライドショー投稿タイプ"スライドショー"を追加
*/
// Register Custom Post Type
function slider_type() {
$labels = array(
'name' => _x( 'スライドショー', 'Post Type General Name', 'textdomain' ),
'singular_name' => _x( 'スライドショー', 'Post Type Singular Name', 'textdomain' ),
@marushu
marushu / enqueue-script.php
Created July 25, 2015 08:04
【キャッシュ対策】css, jsのバージョン番号
<?php
wp_enqueue_style(
'cocoyoka_css',
get_stylesheet_directory_uri() . '/style.css',
array( 'parent_css' ),
date( 'TmdHis', filemtime( get_stylesheet_directory() . '/style.css' ) ),
'all'
);
wp_enqueue_script(
require_once dirname( __FILE__ ) . '/vendor/autoload.php';
$ git pull origin master ← リモートリポジトリと同期
$ git checkout -b DEV_BRANCH master ← 開発ブランチを作成 ///// masterだよ /////////
--- ソースの修正 ---
$ git add -u
$ git commit -m "修正内容"
$ git push origin DEV_BRANCH ← リモートリポジトリの開発ブランチに push
$ git checkout master
$ git pull origin master ← 変更を取り込み(他の人が master に push してるかもなので )
$ git merge DEV_BRANCH ← 開発ブランチをマージ
$ git push origin master
@marushu
marushu / disease_by_year_list.php
Last active August 29, 2015 14:14
フロントフォームから入力したユーザー(投稿者)一覧を出力する
<?php
function disease_data_list() {
echo get_disease_data_list();
}
function get_disease_data_list() {
global $post;
$current_user = wp_get_current_user();
$display_name = esc_html( $current_user->display_name );
if( isset( $_GET[ 'post_id' ] ) || isset( $_GET[ 'user_id' ] ) ) {
$post_id = intval( $_GET[ 'post_id' ] );
@marushu
marushu / exclude-same-title-posts.php
Last active August 29, 2015 14:12
投稿を抽出する際、タイトルが同じ投稿がある場合、同名の投稿の中でIDが一番新しいもののみを出す
<?php
$get_posts_arr = array();
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
$args = array(
'post_type' => 'post',
'numberposts' => 10000,
'posts_per_page' => 100,
'paged' => $paged,
);
$another_way_retrieve_posts = get_posts( $args );