私は実際に、フロント ページに美しいフルページ スライダーがある Design.net テーマ (ピクセル テーマ) を使用したワードプレス Web サイトに取り組んでいます。スライダーには、選択した投稿 (編集ページのメタ ボックス フィールドで [スライドショーで表示] をオンにした投稿) の注目の画像が表示されます。
これらのアイキャッチ画像は、サイトのさまざまなビュー (サムネイルなど) で同じように使用されます。サムネイル用にそれらが必要ですが、ホームページのスライダー用に別の画像 (選択した投稿に関連したもの) が欲しいです。
wordpress 用の「動的注目画像」プラグインを見つけましたが、スライダーのループで 2 番目の注目画像の URL を取得できません。
テーマの場合と同様に、スライダーのコードの一部を次に示します。
<ul>
<?php
$slider_arr = array();
$x = 0;
$args = array(
//'category_name' => 'blog',
'post_type' => 'post',
'meta_key' => 'ex_show_in_slideshow',
'meta_value' => 'Yes',
'posts_per_page' => 99
);
query_posts($args);
while (have_posts()) : the_post();
$thumb = wp_get_attachment_image_src( get_post_thumbnail_id(get_the_ID()), 'full' );
//$thumb = wp_get_attachment_image_src( get_post_thumbnail_id(get_the_ID()), 'large' );
$img_url = $thumb['0'];
?>
<li data-background="<?php echo $img_url; ?>" onclick="location.href='<?php the_permalink(); ?>';" style="cursor:pointer;">
</li>
<?php array_push($slider_arr,get_the_ID()); ?>
<?php $x++; ?>
<?php endwhile; ?>
<?php wp_reset_query(); ?>
</ul>
今、私はプラグインのgithubページにあるコードを入れようとしました:
if( class_exists('Dynamic_Featured_Image') ) {
global $dynamic_featured_image;
$thumb = $dynamic_featured_image->get_featured_images( );
//You can now loop through the image to display them as required
}
代わりに$thumb = wp_get_attachment_image_src( get_post_thumbnail_id(get_the_ID()), 'full' );
ただし、文字列として$thumb
返しますarray
私はいくつかの異なることを試しましたが、私はphpに堪能ではありません.
これが理解できることを願っています。