-1
我正在建立一個網站與ACF和我有兩個不同類別的網頁:文章和故事。Wordpress循環在奇怪的偶數頁在兩個類別
我想建立我的頁面,使它成爲故事中交替文章的列表,但是現在我首先獲取所有文章,然後是所有故事而不是交錯。
您可以在這裏看到的網站http://www.ndstudio.no/wp-mindthegap/
我希望循環是這樣的:
POST 1 (ARTICLE)
POST 2 (STORY)
POST 3 (ARTICLE)
POST 4 (STORY)
但此刻it's這樣的:
POST 1 (ARTICLE)
POST 2 (ARTICLE)
POST 3 (STORY)
POST 4 (STORY)
這是我的代碼
<?php
$args = array(
'cat' => 5,
'post_type' => array('page'),
'order' => 'ASC'
);
query_posts($args);
// The Loop
while (have_posts()) : the_post();
?>
<?php $colour = get_field('colour'); ?>
<div class="<?php print $colour; ?>-wrap">
<div class="first-text-content">
<h1 class="title-page"><?php the_title(); ?></h1>
<?php
// check if the repeater field has rows of data
if(have_rows('block')):
// loop through the rows of data
while (have_rows('block')) : the_row();
?>
<!-- <p><?php the_sub_field('type'); ?><p> -->
<?php
$type = get_sub_field('type');
$quote = get_sub_field('quote');
$text = get_sub_field('text');
if ($type == "text") {
?>
<?php the_sub_field('text'); ?>
<?php
} else if ($type == "quote") {
?>
<div class="quote"><?php the_sub_field('quote'); ?></div>
<?php
}
?>
<?php
endwhile;
else :
// no rows found
endif;
?>
</div>
</div>
<?php
endwhile;
// Reset Query
wp_reset_query();
?>
<!-- STORIES categories -->
<?php
$args = array(
'cat' => 4,
'post_type' => array('page'),
'order' => 'ASC'
);
query_posts($args);
// The Loop
while (have_posts()) : the_post();
?>
<div class="stories">
<div class="stories-length">
<div class="scroll-right"><img src="http://www.ndstudio.no/wp-mindthegap/wp-content/uploads/2015/05/scroll-right.png" /></div>
<img class="intro-image" src="<?php the_field('intro-image'); ?>" alt="" />
<div class="intro-column">
<h1 class="title-page"><?php the_title(); ?></h1>
<?php the_field('intro-text'); ?>
</div>
<?php
// check if the repeater field has rows of data
if(have_rows('content_block')):
//consoleLog(get_field('block'));
// loop through the rows of data
while (have_rows('content_block')) : the_row();
?>
<!-- <p><?php the_sub_field('type'); ?><p> -->
<?php
// the_sub_field is printing the value, which is output into HTML
// get_sub_field is returning the value, which you'll store in a variable
$select = get_sub_field('select');
$textfield = get_sub_field('textfield');
$video = get_sub_field('video');
$quote = get_sub_field('quote');
$bgcolor = get_sub_field('bgcolor');
$image1 = get_sub_field('image1');
$image2 = get_sub_field('image2');
if ($select == "textfield") {
?>
<div class="text-column"><?php the_sub_field('textfield'); ?></div>
<?php
} else if ($select == "video") {
?>
<div class="video-row-2"><div class="article-video-2"><?php the_sub_field('video'); ?></div></div>
<?php
} else if ($select == "quote") {
?>
<div class="nautral-row"><div class="quotes"><?php the_sub_field('quote'); ?></div></div>
<?php
} else if ($select == "image1") {
?>
<div class="<?php print $bgcolor; ?>-row">
<img class="article-image" src="<?php the_sub_field('image1'); ?>" alt="" />
<?php
} else if ($select == "image2") {
?>
<img class="article-image" src="<?php the_sub_field('image2'); ?>" alt="" /></div>
<?php
}
?>
<?php
endwhile;
else :
// no rows found
endif;
?>
</div>
</div>
<?php
endwhile;
// Reset Query
wp_reset_query();
?>
非常感謝您的光臨。