###前提・実現したいこと
いつもお世話になっております。
私が作ったHPではありませんが、WORDPRESSの記事が
表示されなくなったと相談を受けました。
原因がわからず、サイトを調べているうちに、これが原因かなと
想像し、サイトを参考にしながら、修正したところ、
5,'orderby'=>'date','order'=>'DESC');
$myposts = get_posts($args);
foreach($myposts as $post) : setup_postdata($post); ?>
の部分だけが画面に表示されるようになり・・・はまりました。
やりたいことは、ワードプレスで書いた記事を
ホームページ上に表示したいことです。
ご指導よろしくお願いします。
###発生している問題・エラーメッセージ
下記文字がHP上に表示される。
5,'orderby'=>'date','order'=>'DESC'); $myposts = get_posts($args); foreach($myposts as $post) : setup_postdata($post); ?>
###該当のソースコード
<div id="news" > <h2><a href="blog/"><img src="img/news.gif" alt="news" /></a></h2> <div id="feeds_area"> <div id="feeds"></div> </div> <ul> <?php $myposts = get_posts('numberposts=5&orderby=post_date'); foreach($myposts as $post) : setup_postdata($post);?> <li><?php the_time('Y/m/d') ?> <a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li> <?php endforeach; ?> </ul> </div>
上記がもともとあったソースです。
上記のソースの場合は、記事が表示されません。
<ul> <?php $args = array('posts_per_page' => 5, 'orderby'=> 'date', 'order' => 'DESC' ); $myposts = get_posts($args); foreach($myposts as $post) : setup_postdata($post); ?> <li><?php the_time('Y/m/d') ?> <a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li> <?php endforeach; ?> </ul>
見ようみまねで、上記のソースに書き直しました。
すると記事は表示されず、エラーのようにソースの一部が画面に表示されます。
###試したこと
タグのしまい忘れなど、チェックしましたが、PHPとして
何か間違えているところに気付けてません。
###補足情報(言語/FW/ツール等のバージョンなど)
WordPress 4.2.17
回答1件
あなたの回答
tips
プレビュー