サポート » 使い方全般 » 固定ページのサムネイル、タイトル表示

  • 投稿ページの最新5件をサムネイルとタイトル、記事を表示させているのですが、

    固定ページの5件も表示させたいです。

    中階層のカテゴリは表示しなくても良いです。

    ご指導宜しくお願い致します。

9件の返信を表示中 - 1 - 9件目 (全9件中)
  • モデレーター Takuro Hishikawa

    (@hissy)

    get_posts()関数を使う場合、post_typeパラメータを指定することで可能です。

    テンプレートタグ/get posts

    トピック投稿者 tazima3469

    (@tazima3469)

    ご返信ありがとうございます。

    get_posts()で、固定ページの設定はどのようにしたら良いでしょうか?

    ご指導宜しくお願い致します。

    モデレーター Takuro Hishikawa

    (@hissy)

    えーっと、とりあえずリンク先の説明を読んでみてください。
    あるいは、現在投稿ページの最新5件を取得しているコードを掲載してください。

    トピック投稿者 tazima3469

    (@tazima3469)

    ご返信ありがとうございます。

    投稿ページで利用している、新着5件表示のphpになります。

    <?php require('wp-load.php'); ?>
    
    <?php
    $posts = get_posts("numberposts=5&category=&orderby=post_date&offset=0");
    foreach ($posts as $post):
    setup_postdata($post);
    ?>
    <table width="190" border="0" cellspacing="0" cellpadding="0" id="blog_img">
    <tr>
    <td width="55" style="padding-bottom:10px; padding-top:5px;"><a href="<?php the_permalink() ?>" target="_top"><?php $attachments = get_children(array('post_parent' => get_the_ID(), 'post_type' => 'attachment', 'post_mime_type' => 'image', 'orderby' => 'menu_order'));
    if ( ! is_array($attachments) ) continue;
    $count = count($attachments);
    $first_attachment = array_shift($attachments); ?>
    <?php echo wp_get_attachment_image($first_attachment->ID); ?></a></td>
    <td style="padding-bottom:8px;"><a href="<?php the_permalink() ?>" target="_top"><?php the_title() ?></a>
    <br />
    <span style="color:#990000;"><?php the_time('Y.m.d') ?></span></td>
    </tr>
    </table>
    
    <?php endforeach; ?>

    ご指導宜しくお願い致します。

    モデレーター Takuro Hishikawa

    (@hissy)

    posts = get_posts("numberposts=5&category=&orderby=post_date&offset=0");

    posts = get_posts("post_type=page&numberposts=5&orderby=post_date&offset=0");

    トピック投稿者 tazima3469

    (@tazima3469)

    テストしてみました。ありがとうございます。

    一応日付順では表示が可能なのですが
    階層表示にするとすべて一覧が表示されてしまうようでしたが、親階層だけまたは、
    ページ属性の順序の上位5件などにできますでしょうか??

    トピック投稿者 tazima3469

    (@tazima3469)

    コメントも表示させたいです。
    <?php echo mb_substr(strip_tags($post->post_content), 0, 30); ?>

    はどのように設定したら良いでしょうか?

    ご指導宜しくお願い致します。

    モデレーター Takuro Hishikawa

    (@hissy)

    > 親階層だけ
    こちらのページの「サブページかどうかをチェックする」の項をご参照ください。
    条件分岐タグ

    > コメントも表示させたいです。
    > <?php echo mb_substr(strip_tags($post->post_content), 0, 30); ?>
    すみません、ご質問がよくわかりません…。

    トピック投稿者 tazima3469

    (@tazima3469)

    > コメントも表示させたいです。
    > <?php echo mb_substr(strip_tags($post->post_content), 0, 30); ?>

    解決致しました。ありがとうございました。

    > こちらのページの「サブページかどうかをチェックする」の項をご参照ください
    ご指導ありがとうございます。試してみます。

9件の返信を表示中 - 1 - 9件目 (全9件中)
  • トピック「固定ページのサムネイル、タイトル表示」には新たに返信することはできません。