0

これはプラグインのテーマの問題です。私のプラグインは、私が作ったこのテンプレートページで動作します.(変更)

元のファイルproduct-image.php。変更したファイルproduct-image-360.php

商品投稿に 3 つのカスタム フィールドを追加しました。

  • magnified_image_filename- 実行に必要なファイルの名前をプラグインに与えます。
  • magnified_image- 画像へのパスを指定します。
  • 360- class フィールドは、投稿でプリティ フォトを有効にするかどうかを確認するために投稿を識別するために使用されます。

このコードは、グローバルに割り当てられたクラス、つまりprettyPhoto. これによりprettyPhoto、注目の画像から を有効にし、投稿と製品の画像に 360 yes のクラス フィールドを含めるとオフにすることができます。

    global $post,$woocommerce;
    $threesixty = get_post_meta($post->ID, '360', true);
    if ($threesixty == '') {
    wp_register_script( 'prettyPhoto', get_template_directory_uri() . '/includes/js/jquery.prettyPhoto.js', array( 'jquery' ) ); 
    }

ただし、現在は 2 つのproduct-image.phpテンプレートがあります。360 のカスタム フィールドに応じて rel 属性と class 属性を変更する条件ステートメントにそれらを組み合わせるにはどうすればよいですか?

4

1 に答える 1

0

「360」フィールドがない場合は、get_post_meta($post->ID, '360', true); と仮定します。false を返します。

<a 
  itemprop="image" 
  href="<?php echo wp_get_attachment_url( get_post_thumbnail_id() ); ?>" 
  class="<?php echo (TRUE == ($threesixty = get_post_meta($post->ID, '360', true))) ? 'Magic360' : 'somethingElse';?>" 
  rel="<?php echo (TRUE == ($threesixty = get_post_meta($post->ID, '360', true))) ? 'filename:'.$split_name.'-{col}.jpg; magnify:true; magnify-filename:'.get_post_meta($post->ID, 'magnified_image_filename', true).'-{col}.jpg' : 'somethingElse';?>"
>
  //img stuff here
</a>
于 2012-08-16T16:29:47.843 に答える