在搜索了所有已提出的问题后,我无法找到问题的解决方案,这是我找到的最接近的问题:My custom post type displays the [latest post]
我在主页中内置了一个滑动条,但我注意到,经过一段时间的工作,它现在只显示最新的帖子类型。
以下是滑块的当前代码:
<div class="half slide-container">
<ul class="slider">
<?php
$slides = get_posts( array(
\'numberposts\' => 6,
\'post_type\' => \'slides\',
\'orderby\' => \'post_date\'
) );
foreach( $slides as $post ) :
setup_postdata( $post );
$args = array(
\'post_type\' => \'attachment\',
\'numberposts\' => null,
\'post_status\' => null,
\'orderby\' => \'post_date\',
\'order\' => \'ASC\',
\'post_parent\' => $post->ID
);
$attachments = get_posts( $args );
?>
<li data-background="http://www.serps.co.uk/cdn/PG/background14.png">
<?php the_content( ); ?>
</li>
<?php endforeach; ?>
</ul>
</div>
我是个新手。php,但我认为我发现了一些语法错误,但滑块仍然损坏。
我把它改成了这样,但没有用:
<div class="half slide-container">
<ul class="slider">
<?php
$slides = get_posts( array(
\'numberposts\' => \'3\',
\'post_type\' => \'slides\',
\'orderby\' => \'post_date\'
) );
foreach( $slides as $post ) :
setup_postdata( $post );
$args = array(
\'post_type\' => \'attachment\',
\'numberposts\' => \'3\',
\'post_status\' => \'publish\',
\'orderby\' => \'post_date\',
\'order\' => \'ASC\',
\'post_parent\' => $post->ID
);
$attachments = get_posts( $args );
?>
<li data-background="http://www.serps.co.uk/cdn/PG/background14.png">
<?php the_content( ); ?>
</li>
<?php endforeach; ?>
</ul>
</div>
您可以在以下网站上查看此实况:
Polesworth Garage