if ( have_posts() ) : // Start the Loop. echo '<div class="archive-header archive-title" style="margin-bottom:0px;">新着記事</div>'; while ( have_posts() ) : the_post();
追加
if ( have_posts() ) : // Start the Loop. echo '<div class="archive-header archive-title" style="margin-bottom:0px;">新着記事</div>'; while ( have_posts() ) : the_post();
追加
//特定の条件でボディにクラスをつける
add_filter('body_class','my_class_names');
function my_class_names($classes) {
if(is_page( '62' )){
// add 'class-name' to the $classes array
$classes[] = 'list-view';
// return the $classes array
}
return $classes;
}
http://memocarilog.info/wordpress/theme-custom/3001 参考
これで固定ページのクエリポストにも
list-viewをつけて
アーカイブぺーじのtw14のcssを
<?php
/**
* The template for displaying Category pages
*
* @link http://codex.wordpress.org/Template_Hierarchy
*
* @package WordPress
* @subpackage Twenty_Fourteen
* @since Twenty Fourteen 1.0
*/
get_header(); ?>
<section id="primary" class="content-area">
<div id="content" class="site-content" role="main">
<?php //カテゴリ:ライブスケジュールの場合 未来の記事しか出さないよ
if(in_category(4)):
function filter_where($where = '') {
$where .= " AND post_date > '" . date('Y-m-d', strtotime('0 days')) . "'";
return $where;
}
add_filter('posts_where', 'filter_where');
?>
<?php //カテゴリ:ライブスケジュールの場合セットしないといけないよ カテゴリアーカイブではなくなるので下記single_cat_titleはつかえなくなるよ!
query_posts(
array(
'paged' => $paged,
'cat'=> array(4),
'order' => ASC,
));
?>
<?php endif; //カテゴリ:ライブスケジュールの場合★おわり ?>
<?php if ( have_posts() ) : //記事があれば
if(in_category(4))://カテゴリ:ライブスケジュールの場合?>
<header class="archive-header">
<h1 class="archive-title">一覧</h1>
<?php else://カテゴリ:他の場合?>
<header class="archive-header">
<h1 class="archive-title"><?php printf( __( ' %s', 'twentyfourteen' ), single_cat_title( '', false ) ); ?> 一覧</h1>
<?php endif; //カテゴリ:ライブスケジュールの場合★おわり ?>
<?php
// Show an optional term description.
$term_description = term_description();
if ( ! empty( $term_description ) ) :
printf( '<div class="taxonomy-description">%s</div>', $term_description );
endif;
?>
</header><!-- .archive-header -->
<?php
// Start the Loop.
while ( have_posts() ) : the_post();
/*
* Include the post format-specific template for the content. If you want to
* use this in a child theme, then include a file called called content-___.php
* (where ___ is the post format) and that will be used instead.
*/
get_template_part( 'content', get_post_format() );
endwhile;
// Previous/next page navigation.
twentyfourteen_paging_nav();
else :
// If no content, include the "No posts found" template.
get_template_part( 'content', 'none' );
endif;
?>
</div><!-- #content -->
</section><!-- #primary -->
<?php
get_sidebar( 'content' );
get_sidebar();
get_footer();
まずcssで改造
スタイルに追加
/*サイドと上色替え*/
.site:before,.site-header{
background-color: #72DFB8!important;
}
/*アドミンバー色替え*/
.search-toggle,#wpadminbar{
background-color: #FFA70A!important;
}
/*サムネイル ホバー色替え*/
.post-thumbnail{
background-color: #B2B440!important;
}
/*サムネイル 401までマージン*/
@media screen and (min-width: 401px) {
.entry-header .post-thumbnail{margin-bottom:10px;}
}
/*サイドメニュー ヘッダーメニューのカレントカラー*/
.site-navigation .current_page_item > a, .site-navigation .current_page_ancestor > a, .site-navigation .current-menu-item > a, .site-navigation .current-menu-ancestor > a {
color: #FFA70A!important;
}
/*サイドメニュー ヘッダーメニューのホバー上記かれんとよりあとに*/
.site-navigation a:hover {
background-color: #FFA70A!important;
color: #FFFFFF!important;
}
/*シングル 他Pageのぞく ポストサムネイルをエントリーヘッダーに入れたからマージンはいらない*/
.single.full-width.singular .site-content .hentry.has-post-thumbnail,
.full-width .site-content .has-post-thumbnail .entry-header
{
margin-top: 0px!important;
}
3188行目あたり
多分.has-post-thumbnailけした
.list-view .site-content .hentry {
border-top: 1px solid rgba(0, 0, 0, 0.1);
padding-top: 48px;
}
.list-view .site-content .hentry:first-of-type,
/*.list-view .site-content .hentry.has-post-thumbnail*/
/*サムネイル有りも線いるし 一個目はいらない*/
.list-view .site-content .hentry.has-post-thumbnail:first-of-type{
border-top: 0;
padding-top: 0;
}
'. get_the_time('Y年m月d日'). '
' . コード . '
出力では無く 取得 上記は出力前提のため出力される たとえば エコーとか野中
get_the_time('Y年m月d日')
カスタムポストの新着情報
<h3 class="widgettitle">施工例 NEW !!</h3>
<?php
$args = array(
'posts_per_page' => 3,
'post_type' => 'jirei_new', //カスタム投稿名
);
?>
<?php
query_posts( $args );
if ( have_posts () ) :
while ( have_posts() ) :
the_post();
?>
<div class="popular_one">
<div class="popular_sam">
<?php
$i = 0;
$kiji = 1;//この回数でフォーチ終わる。
$fields = $cfs->get('jirei_imgs');
foreach ($fields as $field) :
if($i >= $kiji)://siが3よりおおきくなったら
break;//ループおわり
else://それまではこれで出力
?>
<?php
$title= get_the_title();
$attachment_id = $field['jirei_img'];
$sample_photo = wp_get_attachment_image($attachment_id,'jirei_small',0,array('alt'=>$title,'title'=>$title));?>
<a href="<?php the_permalink(); ?>">
<?php
echo $sample_photo;
?>
</a>
<?php
$i++;//多分繰り返すごとに$iに数値が1つづ増える
endif;
endforeach;
?>
</div>
<h4><div class="popular_title"><a href="<?php the_permalink(); ?>">
<?php the_title(); ?></a></div></h4>
<div class="popular_date" style="padding-top:5px;">
<p><?php get_trim_str(array('str'=>get_post_meta($post->ID,"jirei_disp",true), 'len'=>100)); ?></p>
</div>
</div>
<?php
endwhile;
endif;
?>
<!-----------------リセットクエリ--------->
<?php wp_reset_query(); ?>
新着ブログ
<h3 class="widgettitle">新着ブログ</h3>
<?php
$args = array(
'posts_per_page' => 3,
'cat' => 4,
);
?>
<?php
query_posts( $args );
if ( have_posts () ) :
while ( have_posts() ) :
the_post();
?>
<div class="popular_one">
<div class="popular_sam"><a href="<?php the_permalink(); ?>">
<?php
$title= get_the_title();
the_post_thumbnail('side_new_post_sam',
array('class' => 'blog_sam_img','alt' =>$title, 'title' => $title)
); ?>
</a></div>
<div class="popular_date"><?php the_time('Y/m/d'); ?></div>
<div class="popular_title"><p><a href="<?php the_permalink(); ?>">
<?php the_title(); ?></a></p></div>
</div>
<?php
endwhile;
endif;
?>
<!-----------------リセットクエリ--------->
<?php wp_reset_query(); ?>
新着 サムネイルなし
<h3 class="widgettitle">Information</h3>
<?php
$args = array(
'posts_per_page' => 3,
'cat' => 5,
);
?>
<?php
query_posts( $args );
if ( have_posts () ) :
while ( have_posts() ) :
the_post();
?>
<div class="popular_one">
<div class="popular_sam"><a href="<?php the_permalink(); ?>">
<?php
$title= get_the_title();
the_post_thumbnail('side_new_post_sam',
array('class' => 'blog_sam_img','alt' =>$title, 'title' => $title)
); ?>
</a></div>
<div class="popular_date"><?php the_time('Y/m/d'); ?></div>
<div class="popular_title"><p><a href="<?php the_permalink(); ?>">
<?php the_title(); ?></a></p></div>
</div>
<?php
endwhile;
endif;
?>
<!-----------------リセットクエリ--------->
<?php wp_reset_query(); ?>
css
/*-----------------------------------------------------ウィジェット用-----------------------------------------------------*/
.widgettitle{
font-size: 12px;
margin-top: 20px;
margin-bottom: 30px;
line-height: 44px;
height: 40px;
background-color: #595959;
-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;
color: #FFF;
padding-left: 15px;
border-left-width: 4px;
border-left-style: solid;
border-left-color: #e50012;
}
.widget{
list-style-type: none;
}
/*-----------------------------------------------------wp popular postプラグイン用-----------------------------------------------------*/
.popular-posts{}
.popular_one{
margin-bottom: 8px;
padding-bottom: 8px;
border-bottom-width: 1px;
border-bottom-style: dotted;
border-bottom-color: #CCC;
clear: both;
overflow: hidden;
}
.popular_sam{
float: left;
}
.popular_sam img{
float: left;
background-color: #FFF;
padding: 1px;
border: 1px solid #CCC;
margin-right: 12px;
}
.popular_date{
font-size: 10px;
}
.popular_title{
font-size: 12px;
}
.wpp-views{
color: #FF7737;
}
ポスト関連記事 出力コード
<?php related_posts(); ?>
css
/*-----------------------------------------------------YARPPプラグイン用-----------------------------------------------------*/
.related-post{
height:100%;
}
.related-post{
width:100%;
overflow:hidden;
margin-top:5px;
}
.related-entry {
vertical-align: top;
float: left;
width:123px;
font-size: 13px;
min-height: 210px;
margin-bottom:0px;
padding: 0px 10px 0px 10px;
display: block;
}
.related-entry img{
padding: 4px;
border: #ccc 1px solid;
width: 123px;
height: 123px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 5px;
margin-left: 0px;
}
#post-syokai2{
border-left: 10px solid #999;
padding: 1px 9px;
margin: 5px 0 16px 0;
font-size: 16px;
margin-left: 5px;
}
.kannrenn h3{
background-color: #c1c1ff;
font-size: 14px;
color: #494a41;
margin: 35px 0 10px 0;
padding: 5px 0px 5px 20px;
}
.kannrenn ul{
list-style-type: none;
}
.kannrenn ul li{
float: left;
width: 100px;
line-height: 21px;
margin: 0 13px 0 0;
}
yarpp-template-d1.php
<?php if(have_posts()):?>
<div style="padding-top:0px;"></div>
<h2 id="post-syokai2">関連記事はこちら</h2>
<div class="related-post">
<?php while(have_posts()) : the_post(); ?>
<?php if(has_post_thumbnail()):?>
<h3><div class="related-entry"><a href="<?php the_permalink() ?>"rel="bookmark"title="<?php the_title_attribute(); ?>"><?php $title= get_the_title(); the_post_thumbnail("thumbnail",array( 'alt' =>$title)); ?><?php the_title(); ?></a></div>
<?php else: ?>
<div class="related-entry"><a href="<?php the_permalink() ?>"rel="bookmark"title="<?php the_title_attribute(); ?>">
<img src="<?php echo home_url(); ?>/wp-content/plugins/wordpress-popular-posts/no_thumb.jpg" alt="<?php $title= get_the_title(); echo $title ?>" />
<?php the_title(); ?></a></div></h3>
<?php endif; ?>
<?php endwhile; ?>
</div>
<?php else: ?>
<?php endif; ?>
Auto Post Thumbnail Android 不具合
バージョンあっぷすべし
携帯でアップした画像なのか
サムネイルが表示されなくなった
3.8にあっぷしたら
http://yuhnote.com/2012/06/15/wp3_4-eyecatch-thumbnail/
こちらと同じく。
8番は大丈夫だったからアプリが原因
メディアからサムネイルが消えているのを選び 消して サムネイルを再度作成
これでよし
■コンタクトフォームでのスパム対策 直埋め込み
acceptance-0 送信してよろしいですか?
と認証式にするとよい
http://curious-everything.com/1089-entry.html
ショートコード埋め込み
<?php echo do_shortcode( '[contact-form-7 id="4" title="コンタクトフォーム 1"]' ); ?>
■コンタクトフォームで添付ファイルの最初は1MB
変更は
[file file-359 limit:3000000]
■コンタクトフォーム ファイル名文字化け
やったけど入換え phpmailなんとか
治らなかった
<script> image = new Image(); image.src = "img/top/jc_top2-02.jpg"; image.src = "img/top/jc_top2-07.jpg"; image.src = "img/top/jc_top2-06.jpg"; image.src = "img/menu_put-01_on.jpg"; image.src = "img/menu_put-02_on.jpg"; image.src = "img/menu_put-03_on.jpg"; image.src = "img/menu_put-04_on.jpg"; image.src = "img/menu_put-05_on.jpg"; image.src = "img/top/jc_top2-02.jpg"; </script> </head>
<?php //ターム名リンク無しで取得
$terms = get_the_terms($post->ID, 'art_name');
$names = array();
echo ""; //前の文字
foreach ( $terms as $term ) {
$names[] = $term->slug; //[]にしまうってこと!
}
?>
<?php
$r_posts1 = $cfs->get('kanren_art');
if ($r_posts1) :
?>
<div class="top_titol" style="font-size:24px;">関連アーティースト</div>
<div class="top_new_item_all">
<?php
endif;
?>
<?php //---------------------------------------------関連イベント
$args = array(
'posts_per_page' => -1,
//'orderby' => 'menu_order',
//'order' => 'ASC',
'tax_query' => array(
'relation' => 'AND',
array(
'taxonomy' => 'art_name',
'field' => 'slug',
'terms' => array($names[0],$names[1],$names[2],$names[3],$names[4],$names[5],$names[6],$names[7],$names[8],$names[9],$names[10]),
//'operator'=>'NOT IN'
),
),
'post_type' => 'support_artists', //カスタム投稿名
);
?>
<?php
query_posts( $args );
?>
<?php
if ( have_posts () ) :
while ( have_posts() ) :
the_post();
?>
<a href="<?php the_permalink(); ?>"><div class="artists_box">
<div class="artist_sam">
<?php //写真1枚----------------------------
$title= get_the_title();
$attachment_id = $cfs->get('w126');
$sample_photo = wp_get_attachment_image($attachment_id, 'W126',0,array('alt'=>$title,'title'=>$title));
echo $sample_photo;
?></div>
<div class="artist_disp">
<div class="artist_name"><?php the_title(); ?></div>
<div class="artist_area"><?php echo nl2br(get_post_meta($post->ID,"chiiki",true)); ?></div>
</div>
</div></a>
<!--/Aritist_box-->
<?php
endwhile;?>
<br clear="all" />
</div>
<?php
endif;
?>
<?php wp_reset_query(); ?>
<?php if(post_custom('w452px')): //横写真2枚まで----------------------------?>
<div class="single_art_img2">
<?php
$i = 0;
$kiji = 2;//この回数でフォーチ終わる。
$fields = $cfs->get('w452px_box');
foreach ($fields as $field) :
if($i >= $kiji)://siが2よりおおきくなったら
break;//ループおわり
else://それまではこれで出力
?>
<?php
$attachment_id = $field['w452px'];
$sample_photo = wp_get_attachment_image($attachment_id,'W452',0,array('alt'=>$title,'title'=>$title));
echo $sample_photo;
?>
<?php
$i++;//多分繰り返すごとに$iに数値が1つづ増える
endif;
endforeach;
?>
</div>
<?php endif; //横写真2枚まで----------------------------?>
<?php if(post_custom('w300px')): //縦写真3枚まで----------------------------?>
<div class="single_art_img3">
<?php
$i = 0;
$kiji = 2;//この回数でフォーチ終わる。
$fields = $cfs->get('w300px_box');
foreach ($fields as $field) :
if($i >= $kiji)://siが2よりおおきくなったら
break;//ループおわり
else://それまではこれで出力
?>
<?php
$attachment_id = $field['w300px'];
$sample_photo = wp_get_attachment_image($attachment_id,'W300',0,array('alt'=>$title,'title'=>$title));
echo $sample_photo;
?>
<?php
$i++;//多分繰り返すごとに$iに数値が1つづ増える
endif;
endforeach;
?>
</div>
<?php endif; //縦写真3枚まで----------------------------?>
<?php if(post_custom('w910px')): //大写真1枚----------------------------?>
<div style="padding-bottom:5px;">
<?php $title= get_the_title();
$attachment_id = $cfs->get('w910px');
$sample_photo = wp_get_attachment_image($attachment_id, 'W910',0,array('alt'=>$title,'title'=>$title));
echo $sample_photo;
?>
</div>
<?php endif; ?>
function content(){
$str = get_the_content();
$str = nl2br($str);
$str = preg_replace( '/\n|\r\n/', "", $str );
$str = str_replace( '<br /><br />', "<br />", $str );
$str = str_replace( ' ', "", $str );
echo remove_filter ($str, 'wpautop');
echo $str;
}
http://rize23.com/studyblog/2013/02/08/kiji34-2/
置き換えについて詳しく書いたる
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個目しか入らないようだった。
色々試行錯誤したが
上記以外に使用するのは無理だった、現在。
//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.warna.info/archives/1964/
ヘッダー
<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>
<a href="<?php the_permalink(); ?>#coment">コメント</a>
リンク先
<div style="padding-top:180px; margin-top:-180px;" id="coment"></div>
ウチヤマ
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 '';
?>