Custom Field Suite 関連ポスト

SOLでイベントレポートなどに関連商品を出す方法

フィールドで関連ポストを作成。

入力の際ポスト選択

カスタムポストもできるようだ。

ループ方法

まずフォーチで出すのが基本らしいが

■ サンプル
<?php
$r_posts = $cfs->get('related_post');
if ($r_posts) :
  echo '<ul>'.PHP_EOL;
  foreach ($r_posts as $post_id) :
    $post_obj = get_post($post_id);
?>
    <li><?php echo esc_html($post_obj->post_title); ?></li>
<?php
  endforeach;
  echo '</ul>'.PHP_EOL;
endif;
?>

welcartのため
すでにごちゃごちゃと
フォーチを書いて さらにhave postで出力するのが基本なため
usces_the_item();のセット方法がふぉーちで未定 わからないまだ

なので

$r_posts = $cfs->get('kanren');

から投稿IDを抜き出す。

それを
post__inに代入 の方法でクリア

<?php
$r_posts = $cfs->get('kanren');
if ($r_posts) :
?>

    
<div class="top_titol" style="font-size:24px;">関連商品</div>

    <div class="top_new_item_all">



<?php
endif;
?>

<?php
 query_posts(array('post__in' => array($r_posts[0],$r_posts[1],$r_posts[2],$r_posts[3],$r_posts[4],$r_posts[5],$r_posts[6],$r_posts[7],$r_posts[8],$r_posts[9],$r_posts[10]
 ),'orderby' => 'title', 'order' => 'ASC')); ?>
<?php
if ( have_posts () ) :
    while ( have_posts() ) :
        the_post();
		 usces_the_item();
?>

   <?php if ( usces_is_item() ) : ?> 
     
     <!--ITEM_box-->  
    <a href="<?php the_permalink(); ?>"><div class="top_new_item_box">
      <div class="top_new_item_sam">
      
      <?php
//商品画像
usces_the_itemImage(0, 180, 275); ?>
      </div>
      
      <div class="top_item_name"><?php the_title(); ?></div>
      <?php usces_have_skus(); ?>
      <div class="top_item_disp"><?php usces_the_itemPrice(); ?>円</span><span class="tax"><?php usces_guid_tax(); ?></span></div>
    </div></a>
  <!--/ITEM_box-->      
 <?php endif; ?> 
   
  <?php
    endwhile;?> 
     <br clear="all" />
 </div>
<?php
endif;
?> 

 <?php wp_reset_query(); ?>

最初はカンマ区切りのポストIDを入力しゲットポストめたで代入したが
コンマ区切りは1個目しか入らないようだった。
色々試行錯誤したが
上記以外に使用するのは無理だった、現在。

プロフィールのいらんのを消す css3 カスタムアドミン2

@charset "utf-8";

#profile-page h3,
#profile-page table:nth-of-type(1) tr:nth-child(1),
#profile-page table:nth-of-type(1) tr:nth-child(2),
#profile-page table:nth-of-type(1) tr:nth-child(3),
#profile-page table:nth-of-type(1) tr:nth-child(4),
#profile-page table:nth-of-type(1) tr:nth-child(5),
#profile-page table:nth-of-type(2) tr:nth-child(2),
#profile-page table:nth-of-type(2) tr:nth-child(3),
#profile-page table:nth-of-type(2) tr:nth-child(4),
#profile-page table:nth-of-type(2) tr:nth-child(5),

#profile-page table:nth-of-type(3) tr:nth-child(2),
#profile-page table:nth-of-type(3) tr:nth-child(3),
#profile-page table:nth-of-type(3) tr:nth-child(4),
#profile-page table:nth-of-type(3) tr:nth-child(5),
#profile-page table:nth-of-type(4) tr:nth-child(1),
#footer-ozh-oam,#footer-upgrade
{
    display: none;
}

特定の権限にカスタムアドミンを読み込ます

//CSSで管理画面内のサイドメニューを非表示にする 権限指定
function custom_admin_styles(){
$current_user = wp_get_current_user(); //現在のユーザー情報を取得
        if(check_user_role($current_user,'author')){ //編集者(editor)かチェック
            echo '<link rel="stylesheet" type="text/css" href="' .get_bloginfo('template_directory'). '/custom-admin-css2.css" />';
        }
		if(check_user_role($current_user,'reader')){ //編集者(editor)かチェック
            echo '<link rel="stylesheet" type="text/css" href="' .get_bloginfo('template_directory'). '/custom-admin-css2.css" />';
        }
		
		
    }
    add_action('admin_print_styles', 'custom_admin_styles', 21);

    /*
     * ユーザーの権限をチェックする
     * @param $user ユーザーオブジェクト
     * @param $role ユーザー権限の文字列
     *      (administrator, editor, author, contributor, subscriber)
     */
    function check_user_role($user,$role){
        foreach($user->roles as $user_role){
            if($user_role === $role){
                return true;
            }
        }
        return false;
    }

管理画面改造まとめ

ユーザー投稿者でつくり

http://www.memo.d-marking.com/?p=690

ドロップダウン

メニューエディタで権限を変えていく。

 

ファンクションでアドミンバも消す。

もしくはオリジナルメニュー

http://www.memo.d-marking.com/?p=707

 

クライアントidで表示オプション コメント消す

カスタムポストタイプで

新規追加 編集を書く

 

 

新カレントメニューの作り方 画像置き換え含む

ヘッダー

<script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>

<!--画像カレントホバー-->
<script type="text/javascript" >
$(function(){

 $(".d_navi_main_in li:not(.current) a").each(function(){
  var a = $(this);
  var img = a.find("img");
  var src_off = img.attr("src");
  var src_on = src_off.replace(/^(.+)_off(\.[^\.]+)$/,"$1_on$2");

  $("<img />").attr("src",src_on);

  a.bind("mouseenter focus", function(){
		img.attr("src", src_on);
		});

  a.bind("mouseleave blur", function(){
		img.attr("src", src_off);
		});
	});
});

 //current表示
$(function() {
  if ($('.d_navi_main_in li').hasClass('current')) {
 $(".d_navi_main_in li.current a img").attr("src",$(".d_navi_main_in li.current a img").attr("src").replace(/^(.+)_off(\.[^\.]+)$/,"$1_current$2"));
  }
});
</script>
#d_sidenavi_in ul li.current a {
	color: #71B5FF!important;
	text-decoration: none!important;
	border-top-color: #71B5FF!important;
	border-right-color: #71B5FF!important;
	border-bottom-color: #71B5FF!important;
	border-left-color: #71B5FF!important;
}
<!--メインナビ-->
<div class="d_navi_main_all">
  <div class="d_navi_main_width">
    <div class="d_navi_main_in">
<ul> 
  <li <?php if(is_home()): ?> class="current"<?php endif; ?>>
  <a href="<?php echo home_url(); ?>"><img src="img/main_menu/menu_put-01_off.jpg" width="192" height="70" /></a></li>
  
  <li <?php if(is_page( '21' )): ?> class="current"<?php endif; ?>>
  <a href="<?php echo home_url(); ?>/?page_id=21"><img src="img/main_menu/menu_put-02_off.jpg" width="213" height="70" /></a></li>
  
  <li <?php if(is_page( '19' ) or is_category() or in_category(array(1,2) and is_single())): ?> class="current"<?php endif; ?>>
  <a href="<?php echo home_url(); ?>/?page_id=19"><img src="img/main_menu/menu_put-03_off.jpg" width="199" height="70" /></a></li>
  
  <li <?php if(is_page( '23' )): ?> class="current"<?php endif; ?>>
  <a href="<?php echo home_url(); ?>/?page_id=23"><img src="img/main_menu/menu_put-04_off.jpg" width="194" height="70" /></a></li>
  
  <li <?php if(is_page( '25' )): ?> class="current"<?php endif; ?>>
  <a href="<?php echo home_url(); ?>?page_id=25"><img src="img/main_menu/menu_put-05_off.jpg" width="202" height="70" /></a></li>
  
  
</ul>
    </div class="d_navi_main_in">
  </div class="d_navi_main_width">
</div class="d_navi_main_all">
<!--/メインナビ-->  
         <ul>
    
    <li <?php if(is_page( '28' )): ?> class="current"<?php endif; ?>>
    <a href="<?php echo home_url(); ?>/?page_id=28">理事長ご挨拶</a></li>
    
    <li <?php if(is_page( '30' )): ?> class="current"<?php endif; ?>>
    <a href="<?php echo home_url(); ?>/?page_id=30">メンバー紹介</a></li>
    
    <li class="space"></li>
    <li class="dash"></li>
    <li class="space"></li>
     
    
     <li <?php if(is_category(1) or in_category(array(1) and is_single())): ?> class="current"<?php endif; ?>>
     <a href="<?php echo home_url(); ?>/?cat=1">お知らせ</a></li>
     
    <li <?php if(is_category(2) or in_category(array(2) and is_single())): ?> class="current"<?php endif; ?>>
    <a href="<?php echo home_url(); ?>/?cat=2">活動報告</a></li>
    
    <li class="space"></li>
    <li class="dash"></li>
    <li class="space"></li>
        <li <?php if(is_page( '32' )): ?> class="current"<?php endif; ?>>
        <a href="<?php echo home_url(); ?>/?page_id=32">リンク</a></li>
        
    <li <?php if(is_page( '62' )): ?> class="current"<?php endif; ?>>
    <a href="<?php echo home_url(); ?>/?page_id=62">公開情報</a></li>
    

  
    <li class="space"></li> <li class="space"></li>
    
    <li class="kyuujc"><a href="http://setojcnews.jugem.jp/" target="_blank">旧JC NEWS</a></li>
        

          <li class="space"></li> <li class="space"></li>
          
           <li class="member<?php if(is_page( '64' )): ?> current<?php endif; ?>" ><a href="<?php echo home_url(); ?>/?page_id=64"> メンバーページ</a></li>
          
          
        </ul> 

jquely の問題点

はじめて(気づいたが)確信 バージョンによって
書き方などが変わっているため

新しいバージョンでは 古いスプリクトコードでは 動かないコードが出てくる。

例えば 角丸 corner.js

こいつは1.7.2で動き 1.10.2では動かない

どんどん進化していっているが使用が変わっていって 削除 追加などが繰り返されているらしいので
古いjquelyに合わせて書いていたコードは動かない事がある。

なのでまず jquelyを使えば動くjsコード自体 どのバージョンまで動くか把握しなければ
今後の制作に差し支える。

まとめるべきか。

さらに ワードプレスのwp head の下に書けば すべて動くと思っていたが

今回感じた事は 
手持ちのコードたちが古く
新しいwordpress のプラグインなど(具体的にシンプルライトボックスなど)
は後から読まれる
古いjqelyでは動かない。
もっといえば多分 ワードプレスの読み込むjquelyでしか動かないようだった。

今回この現象を回避するための手段は2つあった

1つはシンプルライトボックスを手持ちの古いバージョンの物を使うか
古い1.7.1でも動くもの

もしくは
実験的に出来た方法で
コンテンツ 拡大コンテンツがあるブログのシングルページにコンテンツ中に新しいバージョンのjクエリを読み込ました。

この場合 wpのjクエリ 1.7.1 コンテンツで再読み込みと三段階ふんでいる

速度や効率的にどうなのか

facebook ウィジェット 色々 XFBML 版

XFBML 版説明
http://tech.nitoyon.com/ja/blog/2012/11/28/xfbml-like/

設置方法詳細

http://hp-guide.com/attract/facebook-page/facebook-comments/

まず1のjavascriptSDKの設置は、<body>の直後に設置します。
そのままコピーして<body>のすぐあとに貼り付ければOKです。


2のXML名前空間の追加は、<html>に「xmlns:fb=”http://ogp.me/ns/fb#”」を追加すると考えていただければOKです。
OGPの設定をしている場合には、すでに他のxmlns属性が追加されていると思いますが、それと同じ要領で追加します。
OGPの設定をしていない場合には画面上に出ている2の部分のコードを<html>と置き換えていただければ結構ですが、OGPを設定している場合には、以下のようになります。

<html xmlns=”http://www.w3.org/1999/xhtml” xmlns:og=”http://ogp.me/ns#” xmlns:fb=”https://www.facebook.com/2008/fbml” xmlns:fb=”http://ogp.me/ns/fb#”>

最後にコメントプラグインを表示させたい箇所に3のコードを貼り付けます。

Facebookコメント
https://developers.facebook.com/docs/plugins/comments/

WP Most Popular で カスタムポストの人気記事をサイドバーに

ウチヤマ
side_custum_post_most_popular.php

まずWP Most Popular
を追加

コードを書く必要が有る
http://2inc.org/blog/2012/03/05/1266/ 説明 すでにカスタムポスト対応済み 元が

//アーリー指定法
$posts = wmp_get_popular( array(
    'limit' => 5,
    'post_type' => array( 'post', 'custom1', 'custom2' ),
    'range' => 'monthly'
) );
//これが元ソース
echo '<div class="widget-container popular-posts">
        <dl>
            <dt>最近1ヶ月の人気の記事</dt><dd><ul>';
$posts = wmp_get_popular( array( 'limit' => 5, 'post_type' => 'post', 'range' => 'monthly' ) );
global $post;
if ( count( $posts ) > 0 ): foreach ( $posts as $post ):
    setup_postdata( $post );
    ?>
    <li><a href="<?php the_permalink() ?>" title="<?php echo esc_attr(get_the_title() ? get_the_title() : get_the_ID()); ?>"><?php if ( get_the_title() ) the_title(); else the_ID(); ?></a></li>
    <?php
endforeach; endif;
wp_reset_postdata();
echo '</ul></dd></dl></div>';
//これがオリジナル改造ソース
<?php
echo '<h2 class="widgettitle">最近1ヶ月の人気の記事</h2>';
//ここから
$posts = wmp_get_popular( array( 'limit' => 5, 'post_type' => 'jirei_new', 'range' => 'monthly' ) );
global $post;
if ( count( $posts ) > 0 ): foreach ( $posts as $post ):
    setup_postdata( $post );
//ここまででループ指定
    ?>
    
    <div class="popular_one">
<div class="popular_sam">
 <?php
//カスタムフィールドスイートのループコード 画像1個だけ 
 $i = 0;
$kiji = 1;//この回数でフォーチ終わる。

$fields = $cfs->get('jirei_imgs');
foreach ($fields as $field) :
if($i >= $kiji)://siが3よりおおきくなったら
break;//ループおわり
else://それまではこれで出力
?>

<?php
 $attachment_id = $field['jirei_img'];
 $sample_photo = wp_get_attachment_image($attachment_id,'jirei_small');?>
 <a href="<?php the_permalink(); ?>">
<?php 
echo $sample_photo;
?>
</a>        
<?php
$i++;//多分繰り返すごとに$iに数値が1つづ増える
endif;
endforeach;
?>
</div>

<div class="popular_title"><a href="<?php the_permalink(); ?>">
<?php the_title(); ?></a></div>
<div class="popular_date" style="padding-top:5px;">
<?php get_trim_str(array('str'=>get_post_meta($post->ID,"jirei_disp",true), 'len'=>100)); ?>

</div>

</div>

    
    
    <?php
//これがループとじ
endforeach; endif;
wp_reset_postdata();
echo '';
?>

縦横比によって出力する画像サイズを分ける(分岐)

//カスタムフィールドスイートで今回は使う
 <?php
$fields = $cfs->get('jirei_imgs');
foreach ($fields as $field) :
?>

<?php
 $attachment_id = $field['jirei_img'];
 
 
 $sample_photo = wp_get_attachment_image_src($attachment_id,'jirei_big_height');
 $sample_photo2 = wp_get_attachment_image($attachment_id,'jirei_big');
 $sample_photo3 = wp_get_attachment_image($attachment_id,'jirei_big_height');
 ?>
<a href="#">

<?php if($sample_photo[1] > $sample_photo[2]): ?>
<?php 
echo $sample_photo2;
?>
<?php else: ?>
<?php 
echo $sample_photo3;
?>
<?php endif; ?>
</a>

<?php
endforeach;
?>

分析 効率化バージョン

<?php
 $attachment_id = $field['jirei_img'];//ループギャラリーの画像を取得
//ここから分岐
 $sample_photo = wp_get_attachment_image_src($attachment_id,'jirei_big_height');//wp_get_attachment_image_srcで切り抜かないバージョンサイズを取得
 ?>
<a href="#">

<?php if($sample_photo[1] > $sample_photo[2]): //横が縦より大きい場合?>
<?php 
 $sample_photo2 = wp_get_attachment_image($attachment_id,'jirei_big'); //切り抜いたバージョン収納
echo $sample_photo2;
?>
<?php else: ?>
<?php 
$sample_photo3 = wp_get_attachment_image($attachment_id,'jirei_big_height');//切り抜かないバージョン収納
echo $sample_photo3;
?>
<?php endif; ?>
</a>

ファンクションに

//サムネイルサイズ増やす trueが強制切り抜き
add_image_size( 'jirei_big', 703, 467,true);//ギャラリー横用
add_image_size( 'jirei_big_height', 703, 467); //ギャラリー正方形 縦用

うまくいかなかったが勉強になったとおもったらできた。the_contentを文字数指定して 改行を反映させながら表示 (get_trim_str を使って…有無)

最終 最初に改行が入ってしまう。
コード


<?php
$my_content = get_the_content(); //コンテンツ取得
$my_content = preg_replace("|(<img[^>]+>)|si","",$my_content); //イメージ要素をのぞく
$my_content2 = strip_tags($my_content); //タグをのぞく
?>
<?php echo nl2br(get_trim_str(array('str'=>$my_content2, 'len'=>100,'echo' => false))); ?>
//改行されてるところにbrを挿入する さらに独自関数 get_trim_strを使う echoをファルスにする。

とおもったができた。

<?php
$my_content = get_the_content(); //コンテンツ取得
$my_content = preg_replace("|(<img[^>]+>)|si","",$my_content); //イメージ要素をのぞく
$my_content = wpautop($my_content); //br p を調整
$my_content = strip_tags($my_content); //タグをのぞく

?>
<?php echo nl2br(get_trim_str(array('str'=>$my_content, 'len'=>100,'echo' => false))); ?>
//改行されてるところにbrを挿入する さらに独自関数 get_trim_strを使う echoをファルスにする。

文字数を指定して取得する関数

http://qiita.com/hisa_k/items/cb96565068426e261690

ファンクション

<?php
/**
* @function get_trim_str
* @param str(string), len(int), suffix(string), echo(bool)
* @return string
*/
if(!function_exists('get_trim_str')){
    function get_trim_str($args = ''){

        $defaults = array(
            'str' => '',
            'len' => 30,
            'suffix' => '..',
            'echo' => true
        );
        $args = wp_parse_args($args, $defaults);
        extract($args, EXTR_SKIP);

        $str = esc_html($str);
        $len = intval($len);
        $suffix = esc_html($suffix);

        if(mb_strlen($str, 'UTF-8') > $len){
            $output = mb_substr($str, 0, $len, 'UTF-8').$suffix;
        }else{
            $output = $str;
        }

        if($echo){
            echo $output;
        }else{
            return $output;
        }
    }
}
?>

パラメータ

str(取り出したい文字列を含む文字列)

len(取り出す文字数を指定)

30(正数)初期値
suffix(接尾辞)

..(文字列)初期値
echo (出力)

1(true)初期値
2(false)
使用例

抜粋の文字数を指定して表示したい場合

<?php get_trim_str(array('str'=>get_the_excerpt(), 'len'=>100)); ?>
<?php get_trim_str(array('str'=>get_post_meta($post->ID,"jirei_disp",true), 'len'=>100)); ?>

忘れてたSEO これが最強か

<div style="text-align:right; padding-right:40px; margin-top:-20px; font-size:10px; color:#E7AC80; margin-bottom:70px;">名古屋市昭和区御器所の美容室/ヘアサロン/美容院 R advance</div>

ブログ投稿の
上と下に

アーカイブ シングルとも

シングルだったら

個別投稿ページ
<?php is_single() ?>

<?php else: //それ以外だったら?>
 
<?php endif; ?>

個別投稿のページ(または添付ファイルページ・カスタム投稿タイプの個別ページ)が表示されている場合。固定ページには適用されない。
is_single( '17' ) 

ID 17の投稿が表示されている場合。
is_single( 'Irish Stew' ) 

"Irish Stew" というタイトルの投稿が表示されている場合。
is_single( 'beef-stew' ) 

"beef-stew" という投稿スラッグの投稿が表示されている場合。
is_single( array( 17, 'beef-stew', 'Irish Stew' ) ) 

ID が 17、投稿スラッグが "beef-stew"、またはタイトルが "Irish Stew" のいずれかにあてはまる投稿が表示されている場合。
is_single( array( 17, 19, 1, 11 ) ) 

Returns true when the single post being displayed is either post ID 17, post ID 19, post ID 1, or post ID 11.
is_single( array( 'beef-stew', 'pea-soup', 'chili' ) ) 

Returns true when the single post being displayed is either the post_name "beef-stew", post_name "pea-soup" or post_name "chili".
is_single( array( 'Beef Stew', 'Pea Soup', 'Chili' ) ) 

Returns true when the single post being displayed is either the post_title "Beef Stew", post_title "Pea Soup" or post_title "Chili".
注: この関数は投稿 ID、投稿タイトル、または投稿名を区別しません。投稿 ID が「17」の投稿をリクエストした場合、タイトルや投稿スラッグが「17」の投稿が表示されることがあります。

ページだったら


<?php if(is_page()): ?>

<?php else: //それ以外だったら?>

<?php endif; ?>

is_page() 
固定ページが表示されている場合。

is_page( '42' ) 
ID 42の固定ページが表示されている場合。

is_page( 'About Me And Joe' ) 
"About Me And Joe"というタイトルの固定ページが表示されている場合。

is_page( 'about-me' ) 
"about-me"という投稿スラッグの固定ページが表示されている場合。

is_page( array( 42, 'about-me', 'About Me And Joe' ) ) 
ID が 42、投稿スラッグが "about-me"、またはタイトルが "About Me And Joe" のいずれかにあてはまる固定ページが表示されている場合。

is_page( array( 42, 54, 6 ) ) 
ID が 42、54、または6のいずれかの固定ページが表示されている場合。

TOP スライダー 改ページフェード出ない様に

<div id="main_contents_top_fade">
<div id="main_contents_top">
<img src="img/top/jc_top2-04.jpg" width="1000" height="343">
<img src="img/top/jc_top2-01.jpg" width="1000" height="343">
<img src="img/top/jc_top2-03.jpg" width="1000" height="343">
<img src="img/top/jc_top2-02.jpg" width="1000" height="343">
<img src="img/top/jc_top2-05.jpg" width="1000" height="343">
<img src="img/top/jc_top2-08.jpg" width="1000" height="343">
<img src="img/top/jc_top2-07.jpg" width="1000" height="343">
<img src="img/top/jc_top2-06.jpg" width="1000" height="343"> 
</div id="main_contents_top">
</div id="main_contents_top">
#main_contents_top_fade {
	width: 1000px;
	height: 343px;
	margin-bottom: 20px;
	}
#main_contents_top {
	width: 1000px;
	margin-bottom: 20px;
	position: relative;
	overflow: hidden;
	height: 343px;	/*display: none;*/
	background-color: #FFF;
	display: none;
}
#main_contents_top img {
	top: 0;
	left: 0;
	position: absolute;
}
<!--TOPフェード-->
<script type="text/javascript">
$(function(){
	var setImg = '#main_contents_top';
	var fadeSpeed = 1500;
	var switchDelay = 5000;

	$(setImg).children('img').css({opacity:'0'});
	$(setImg + ' img:first').stop().animate({opacity:'1',zIndex:'20'},fadeSpeed);

	setInterval(function(){
		$(setImg + ' :first-child').animate({opacity:'0'},fadeSpeed).next('img').animate({opacity:'1'},fadeSpeed).end().appendTo(setImg);
	},switchDelay);
});
</script>   

<!--フェードイン-->
<script type="text/javascript">
$(document).ready(function() {
$('#main_contents_top').fadeIn(0);
});
</script>

アドミンバー 管理画面 お客さん

ファンクションへ

アドミンバー

//オリジナルアドミンバーメニュー
add_action('admin_bar_menu', 'customize_admin_bar_menu', 9999);

function customize_admin_bar_menu($wp_admin_bar){
    $title = sprintf(
       
        '瀬戸青年会議所'
    );
    $wp_admin_bar->add_menu(array(
        'id'    => 'bookpress-app',
        'meta'  => array(),
        'title' => $title,
        'href'  => home_url()
    )); 
	$wp_admin_bar->add_menu(array(
    'parent' => 'bookpress-app', // 親メニューのIDを指定する
    'id'     => 'bookpress-app-sub4',
    'meta'   => array(),
    'title'  => '管理画面へ',
    'href'   => home_url('/wp-admin/')
));
	$wp_admin_bar->add_menu(array(
    'parent' => 'bookpress-app', // 親メニューのIDを指定する
    'id'     => 'bookpress-app-sub',
    'meta'   => array(),
    'title'  => 'JC NEWSを書く',
    'href'   => home_url('/wp-admin/post-new.php')
));
$wp_admin_bar->add_menu(array(
    'parent' => 'bookpress-app', // 親メニューのIDを指定する
    'id'     => 'bookpress-app-sub2',
    'meta'   => array(),
    'title'  => 'ファイルをアップロード',
    'href'   => home_url('/wp-admin/post-new.php?post_type=member_only')
));

$wp_admin_bar->add_menu(array(
    'parent' => 'bookpress-app', // 親メニューのIDを指定する
    'id'     => 'bookpress-app-sub3',
    'meta'   => array(),
    'title'  => 'ログアウト',
    'href'   => wp_logout_url(home_url())
));
}




//アドミンバー内容消す
add_action('admin_bar_menu', 'customize_admin_bar_menu2', 9999); // 優先順位は大きめで!

function customize_admin_bar_menu2($wp_admin_bar){
    // Adminバー左側
    $wp_admin_bar->remove_node('wp-logo');     // 一番左のWordPressのロゴを消す。
    $wp_admin_bar->remove_node('site-name');   // 左から2番めのサイト名を消す。
    $wp_admin_bar->remove_node('new-content'); // 「+ 新規」ってメニューを消す。

    // Adminバー右側
    $wp_admin_bar->remove_node('my-account'); // アカウントのメニューを消す。
    $wp_admin_bar->remove_node('search');     // 検索のメニューを消す。
}

ダッシュボード

// ダッシュボードウィジェット非表示
function example_remove_dashboard_widgets() {
 if (!current_user_can('level_10')) { //level10以下のユーザーの場合ウィジェットをunsetする
 global $wp_meta_boxes;
 unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now']); // 現在の状況
 unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_comments']); // 最近のコメント
 unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links']); // 被リンク
 unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']); // プラグイン
 unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press']); // クイック投稿
 unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_recent_drafts']); // 最近の下書き
 unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']); // WordPressブログ
 unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']); // WordPressフォーラム
 }
 }
add_action('wp_dashboard_setup', 'example_remove_dashboard_widgets');




//☆--オリジナルメニューを追加
function example_dashboard_widget_function() {
 echo '
  <div class="da d1"><a href="./post-new.php">新規 JC NEWS</a></div>
  <div class="da d1"><a href="edit.php?post_type=member_only">新規 ファイルアップロード</a></div>
 <div class="da d6"><a href="post-new.php?post_type=public_information">新規 公開情報</a></div>
 <div style="clear:both"></div>
 ';
}
function example_add_dashboard_widgets() {
 wp_add_dashboard_widget('example_dashboard_widget', '更新', 'example_dashboard_widget_function');
}
add_action('wp_dashboard_setup', 'example_add_dashboard_widgets' );
//オリジナルメニューを追加--☆
/*ダッシュボードメニューcss*/
.da{
	float: left;
	padding-top: 10px;
	padding-right: 5px;
	padding-bottom: 10px;
	padding-left: 5px;
}


.da a{
	padding: 15px;
	background-color: #4091B4;
	color: #FFF;
	    -webkit-border-top-left-radius: 5px;  
    -webkit-border-top-right-radius: 5px;  
    -webkit-border-bottom-right-radius: 5px;  
    -webkit-border-bottom-left-radius: 5px;  
    -moz-border-radius-topleft: 5px;  
    -moz-border-radius-topright: 5px;  
    -moz-border-radius-bottomright: 5px;  
    -moz-border-radius-bottomleft: 5px;