WordPressで、PDFへの直リンクのアドレス固定にしたい時の対応メモ。
PDF入力用カスタムフィールドを用意
固定ページからPDF用カスタムフィールドへ入力
表示させたい固定ページテンプレートにコードを設置
<?php $pdf_data = get_field(‘field_name’,$post->ID); if($pdf_data): header("Location:". $pdf_data); exit; else: endif; ?>
WordPressで、PDFへの直リンクのアドレス固定にしたい時の対応メモ。
PDF入力用カスタムフィールドを用意
固定ページからPDF用カスタムフィールドへ入力
表示させたい固定ページテンプレートにコードを設置
<?php $pdf_data = get_field(‘field_name’,$post->ID); if($pdf_data): header("Location:". $pdf_data); exit; else: endif; ?>
固定ページに設置したリピーターフィールドを呼び出してぐるぐる
<ul> <?php $the_query = new WP_Query( 'page_id=130' );//postid 130を指定 if ($the_query->have_posts()) : while ( $the_query->have_posts() ) : $the_query->the_post();?> <?php while(the_repeater_field('xxx_repeat', $post->ID)):?> <li> <a href="<?php the_sub_field('xxx_url');?>" target="_blank"> <img src="<?php the_sub_field('xxx_img');?>" /> </a> </li> <?php endwhile ; endwhile ; endif ; wp_reset_postdata();?> </ul>