HTMLでPDFファイルを開くとき、表示するページを指定する。
ずっと知らなかったのでメモ。
例:PDFファイルの4ページ目を表示
http://www.myserver.com/myfile.pdf#page=4
元情報
https://helpx.adobe.com/jp/acrobat/kb/226119.html
HTML ページから PDF ファイルの特定の場所へのリンクを作成する方法
【追記】
表示の倍率も変えられるとのこと。
HTMLでPDFファイルを開くとき、表示するページを指定する。
ずっと知らなかったのでメモ。
例:PDFファイルの4ページ目を表示
http://www.myserver.com/myfile.pdf#page=4
元情報
https://helpx.adobe.com/jp/acrobat/kb/226119.html
HTML ページから PDF ファイルの特定の場所へのリンクを作成する方法
【追記】
表示の倍率も変えられるとのこと。
やり方2つ。
//その1 <?php //newマークを出す function new_mark(){ $today = get_the_time("Y-m-d"); $today2 = date("Y-m-d", strtotime("-2 day")); $today5 = date("Y-m-d", strtotime("-5 day")); if($today2 < $today){$icon =' <img src="http://xxx/images/new2day.png">';} //2日までこちらを表示 elseif($today5 < $today){$icon =' <img src="http://xxx/images/new5day.png">';} //5日まではこちら else{$icon ="";} echo $icon; } ?> <?php new_mark() ?>//NEWマーク表示 //その2 <?php //newマークを出す function new_mark2(){ $time = time(); if (strtotime('+2 day', get_the_date('U')) > $time) { $icon =' <img src="http://xxx/images/new2day.png" >';} //2日までこちらを表示 elseif (strtotime('+5 day', get_the_date('U')) > $time) { $icon =' <img src="http://xxx/images/new5day.png" >';} //5日まではこちら echo $icon; } ?> <?php new_mark2() ?>//NEWマーク表示
WordPressのループ内で、変数をon/off(01反転)させたい時。
<?php $flag =''; ?> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> //何かの処理 <?php $flag = !$flag;//01反転処理 ?> //何かの処理 <?php endwhile; // 繰り返し処理終了 endif; ?>
下記でもいいのかな。
$flag = 0; //中略 $flag = 1 - $flag;//反転処理
三項演算子でやる方法もあるらしい。
> 条件式 ? 式1 : 式2
> 条件式を評価し、TRUEであれば式1、FALSEであれば式2を返します。
下記でいうと、$flagに何か入っていれば空に、空なら1を代入。
$flag = ( $flag ) ? '' : 1;//反転処理
リピーターフィールド内、サブフィールドの値を取得。
もっと簡単なやり方がありそう。。
<?php $int_area = get_field('int-area');//int-area(リピータフィールド名)から配列を取得 $first_txt = array_slice($int_area[0],1,1);//array_slice値指定 $next_txt = current( $first_txt );//値を取り出す echo $next_txt;//出力 ?>