私はこれを説明できるようにしようとしていますので、私と一緒に裸にしてください。Wordpress index.phpをsingle.phpにリンクする
私は現在、最初からコード化したWebサイトで作業していますが、クライアントがバックエンドを望んでいるため、wordpressと統合しています。
ここに私の問題ですが、私は主なブログ記事(これまでのところうまくいきました)にindex.phpを使用しています。しかし、私がしたいのは、記事の抜粋だけです(簡単な要約)。そして、ユーザーがその特定の記事/投稿の全ページを見るために「もっと読む」リンクをクリックできるようにします(私が間違っていないのであれば)single.phpであると仮定します。
ここで私が行っているのは、メインブログページ(つまりindex.php - 私はここでは、ページ全体の関連はありませんPHPコード):
<div id="content">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td style="vertical-align: text-top; padding-right: 20px;"><h1>Blog</h1></td>
<td style="vertical-align: text-top; padding-left: 20px;">
<h1>Archives</h1>
<select name="archive-dropdown" onchange="document.location.href=this.options[this.selectedIndex].value;">
<option value=""><?php echo esc_attr(__('Select Month')); ?></option>
<?php wp_get_archives('type=monthly&format=option&show_post_count=1'); ?>
</select>
</td>
<tr>
<td style="padding-right: 20px;">
<?php
$temp = $wp_query;
$wp_query= null;
$wp_query = new WP_Query();
$wp_query->query('posts_per_page=5' . '&paged=' . $paged);
while ($wp_query->have_posts()) : $wp_query->the_post();
?>
<div style="background-color: #fff; margin-top: 0px; padding: 20px 20px 20px 20px; border-color: #819cc7; border-style: solid; border-width: thin;">
<h2><a href="<?php $permalink = get_permalink($id); ?>"><?php the_title(); ?></a></h2>
<p><?php the_post_thumbnail(); ?></p>
<p><?php the_content($more_link_text , '' , $more_file); ?></p>
<p><?php _e('Filed under:'); ?> <?php the_category(', ') ?> <?php _e('by'); ?> <?php the_author(); ?><p>
<p><?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?> <?php edit_post_link('Edit', ' | ', ''); ?>
<p>Date posted: <?php the_date(); ?></p>
<!--Don't know if I need the two lines below
<p><?php //get_post_permalink(); ?></p>
-->
</div>
<p><?php endwhile; ?></p>
<?php $wp_query = null; $wp_query = $temp; ?>
</td>
<td style="padding-left: 20px;"> </td>
</tr>
</table>
</div>
そして、これは私が私のsingle.phpのページを持っているコードです:
<?php get_header(); ?>
<section>
<article id="white_bg">
<div class="content_border">
<div id="content">
<?php if(have_posts()) : ?><?php while(have_posts()) : the_post(); ?>
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<p><?php the_post_thumbnail(); ?></p>
<p><?php the_content(); ?></p>
<p><?php _e('Filed under:'); ?> <?php the_category(', ') ?> <?php _e('by'); ?> <?php the_author(); ?></p>
<p><?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?> <?php edit_post_link('Edit', ' | ', ''); ?></p>
<br />
<?php comments_template(); ?>
<?php endwhile; ?>
<div>
<?php previous_post_link('< %link') ?> <?php next_post_link(' %link >') ?>
</div>
<?php endif; ?>
</div>
</div>
</article><!--end main article-->
</section><!--end main content section-->
<?php get_footer(); ?>
私は今数週間はこれを解読しようとしているので、どんな助けでも大歓迎です。
私は単純に要約された記事/投稿を見て、読んだらもっと読むことができればsingle.phpに行くことができます。
可能であれば、読んでいただきありがとうございます!
こんにちはダニエル、まずは上の任意のより多くの必要がある場合は...私の質問を読んで、それに答えるために時間を割いていただきありがとうございます。 私は実際に 'the_excerpt'を使用しようとしましたが、正常に動作しました。しかし、私の問題は、コーディングで 'the_excerpt'を使用して 'read more'リンクをクリックすると、記事全体を表示する代替ページにリンクされないということです。代わりに、「もっと読む」リンクにカーソルを合わせると、既に表示されている同じページにリンクしています。私の質問はもっとはっきりしていなかったのは残念です。追加の助けをいただければ幸いです。ありがとうございました! – KRS77