Skip to content

Instantly share code, notes, and snippets.

View healingsolutions's full-sized avatar

healingsolutions healingsolutions

View GitHub Profile
@healingsolutions
healingsolutions / headline_nav.php
Created December 25, 2018 11:35
WordPressに目次を入れる
add_filter( 'the_content','get_index_essence',10);
function get_index_essence( $content ) {
global $post_type_set;
if( in_array('display_index_nav',$post_type_set) ){
$check_index = true;
}else{
$check_index = false;
}
@healingsolutions
healingsolutions / wp_keywords_suggest.php
Last active October 10, 2018 05:54
Google Suggest for WordPress
add_action('admin_menu', 'add_keywords');
add_action('save_post', 'save_keywords');
function add_keywords(){
add_meta_box('keywords', 'キーワード', 'insert_keywords', , 'normal', 'high');
}
function insert_keywords(){
global $post;
@healingsolutions
healingsolutions / get_paged_nav_title.php
Last active September 9, 2018 18:38
WordPressの改ページでもタイトルがナビゲーションに出るようにする
//===============================================
//get_next_page title
function get_paged_nav_title( $post =null ){
global $page;
$max_page = mb_substr_count($post->post_content, '<!--nextpage-->') + 1;
$pattern= '/\<h\d{1}(.+?)?\>(.+?)\<\/h\d{1}>/s';
if( $max_page >= $page && $page !== 1 ){
@healingsolutions
healingsolutions / add_keywords_columns.php
Last active September 6, 2018 17:50
文字数のカウントと、設定したキーワードの表示回数を計測する > functions.phpに追記
// CSSのラベルの設定などは、各自で行なってください
// get_post_meta($post->ID, 'keywords', true); を使っているので、keywordsというカスタムフィールドを作成してください
//
//seo columns
//表示したい投稿タイプを設定
$theme_opt['post_type'] = array('post','blog');
if( !empty( $theme_opt['post_type'] ) && is_admin() ){
foreach( $theme_opt['post_type'] as $post_type => $value ){
@healingsolutions
healingsolutions / admin_style.scss
Last active September 3, 2018 19:52
タイトルと本文の文字数を、記事一覧にカラムとして表示(負荷については自己判断でお願いします)
.wp-list-table #words_count {
width: 280px; }
.wp-list-table .column_badge {
color: white;
padding: 3px 7px;
margin-left: 10px;
border-radius: 4px;
font-size: 90%; }
function set_post_attachment_loop(){
if( !empty($_GET) && $_GET['set_post_attachment'] ){
$args = array(
'post_type' => 'post',
'posts_per_page' => -1,
'meta_key' => '_thumbnail_url',
'meta_value' => 'null',
@healingsolutions
healingsolutions / set_post_attachment
Last active September 3, 2018 02:14
set post attachment from meta_key in exported file
function set_post_attachment(){
global $post;
$_custom = get_post_custom($post->ID);
if( !empty($_custom['_thumbnail_url']) ){
set_new_attachment($_custom['_thumbnail_url'][0]);
}
@healingsolutions
healingsolutions / add in functions
Last active September 3, 2018 02:14
add export filter
function set_attach_check(){
$attach_check = [];
return;
}
add_action( 'export_wp', 'set_attach_check' );
function add_attachment_url( $post ){
global $post;
global $attach_check;
@healingsolutions
healingsolutions / functions.php
Last active June 1, 2018 22:28
papa-bu wordpress theme function
/***********************************************
* ユーザープロフィールの項目のカスタマイズ
***********************************************/
function my_child_meta($contactmethods) {
//項目の追加
$contactmethods['childname_1'] = '一人目のお名前';
$contactmethods['childbirth_1'] = 'お誕生日';
return $contactmethods;