私はテーマを作成し、category.phpページにいくつかの完全な投稿を表示したいと思います。これを2または1に簡単に)、次にカテゴリ内の残りの投稿をタイトルリンクとして表示します。catgegoryページに3つの完全な記事を表示し、残りの投稿をタイトルとして残す
自分の投稿をスタイリングしてカスタムフィールドを追加するために、私のループにかなりのHTMLがありますので、すべてのコードを残念ですが、これは私のcategory.phpページの外観です。私はうまくいきませんでしたので、編集して元のコードを表示してください。私はThe Loopを編集するのに幾分新しいので、できるだけ説明/明快さを高く評価します。
<?php
/**
* The template for displaying Category Archive pages.
*/
get_header(); ?>
<div id="primary" class="<?php
$category = get_the_category();
echo $category[0]->cat_name;
?>">
<div id="feature-container" class="full-width-container">
<div class="full-width-container content-page" id="tagline-wrapper">
<div id="left-black"></div>
<div class="page-width-container">
<div id="tagline-box">
<h1 class="category-title">Transactions</h1>
</div>
</div>
</div>
</div>
<div id="content-wrapper">
<div id="project-menu" class="page-width-container">
<?php wp_nav_menu(array('theme_location' => 'project-types')); ?>
</div>
<div id="content" role="main" >
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="story-container" class="module-container">
<div class="our-story">
<div class="story-image">
<?php
// check if the post has a Post Thumbnail assigned to it.
if (has_post_thumbnail()) {
the_post_thumbnail();
}
?>
</div>
<div class="story-text">
<article class="post" id="post-<?php the_ID(); ?>">
<div class="entry-container">
<h2><a href="<?php the_permalink() ?>#content" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
<div class="project-details">
<p><span class="details-location"><?php
global $wp_query;
$postid = $wp_query->post->ID;
echo get_post_meta($postid, '_project-location', true);
wp_reset_query();
?></span><br />
<span class="details-funding"><?php
global $wp_query;
$postid = $wp_query->post->ID;
echo get_post_meta($postid, '_funding-type', true);
wp_reset_query();
?> | <?php
global $wp_query;
$postid = $wp_query->post->ID;
echo get_post_meta($postid, '_funding-source', true);
wp_reset_query();
?></span><br />
<span class="details-value"><?php
global $wp_query;
$postid = $wp_query->post->ID;
echo get_post_meta($postid, '_project-value', true);
wp_reset_query();
?></span></p>
</div>
<div class="entry">
<?php the_content(); ?>
<?php wp_link_pages(array('before' => __('Pages: ','html5reset'), 'next_or_number' => 'number')); ?>
</div>
<?php edit_post_link(__('Edit this entry','html5reset'), '<p>', '</p>'); ?>
</div>
</article>
</div>
</div>
</div>
<?php endwhile; endif; ?>
</div><!-- #content -->
</div>
</div><!-- #primary -->
<?php get_footer(); ?>
3件の投稿を取得するために$ per_pageを3に変更し、whileループでカウンタを使用してください。counterが2より大きい場合はthe_content()を呼び出してください。@ Devonanne –
ありがとうございます。上記のコードを変更しますか?変更する部分をまだ完全には明らかにしていません。 – Devonanne
こんにちは、条件付きループを作成することができます –