2016-10-12 6 views

答えて

1

コードの下に試してみてください。

<?php // get all the categories from the database 
$cats = get_categories(); 
// loop through the categries 
foreach ($cats as $cat) { 
// setup the cateogory ID 
$cat_id= $cat->term_id; 
// Make a header for the cateogry 
echo “<h2>”.$cat->name.”</h2>”; 
// create a custom wordpress query 
query_posts(“cat=$cat_id&post_per_page=100″); 

if (have_posts()) : while (have_posts()) : the_post(); ?> 

<?php // create our link now that the post is setup ?> 

<a href=”<?php the_permalink();?>”><?php the_title(); ?></a> 

<?php echo ‘<hr/>’; ?> 

<?php endwhile; endif; 
// done our wordpress loop. Will start again for each category ?> 

<?php } // done the foreach statement ?> 
0

方法私はこのような投稿の数を無制限にして新しいWPクエリを3回呼び出すことです:

<?php 
    $myposts = get_posts('numberposts=-1&category=CATNUMBER'); 
    foreach($myposts as $post) : setup_postdata($post); 
?> 
<div class="eachPost"> 
    <div class="eachImage"> 
     <?php the_post_thumbnail('full'); ?> 
    </div> 
    <h2><?php the_title(); ?></h2> 
    <?php the_content(); ?> 
</div> 
<?php endforeach;?> 

CATNUMBERをカテゴリIDとrそれを3回エフェクトする。お役に立てれば。

関連する問題