2つ出力 3つ あれば ALT タイトル

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?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枚まで----------------------------?>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?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枚まで----------------------------?>

あれば1つ出力 リンク無しタイトルALT

1
2
3
4
5
6
7
8
9
10
11
12
<?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; ?>

使い道ないかもしれんが 改行制御ファンクション

1
2
3
4
5
6
7
8
9
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( '&nbsp;', "", $str );
   echo remove_filter ($str, 'wpautop');
   echo $str;
}

http://rize23.com/studyblog/2013/02/08/kiji34-2/

置き換えについて詳しく書いたる

Custom Field Suite 関連ポスト

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

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

入力の際ポスト選択

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

ループ方法

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
■ サンプル
<?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();のセット方法がふぉーちで未定 わからないまだ

なので

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

から投稿IDを抜き出す。

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?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個目しか入らないようだった。
色々試行錯誤したが
上記以外に使用するのは無理だった、現在。