Php 3个职位(配置查询参数)
我是新来的,需要一些帮助。我的主题中有三个帖子循环位置。 我的第一个循环显示粘贴帖子或最后一篇帖子:Php 3个职位(配置查询参数),php,wordpress,Php,Wordpress,我是新来的,需要一些帮助。我的主题中有三个帖子循环位置。 我的第一个循环显示粘贴帖子或最后一篇帖子: <?php $args = array( 'posts_per_page' => 1, 'post__in' => get_option( 'sticky_posts' ), 'ignore_sticky_posts' => 1, ); query_posts($args); if ( have_posts() )
<?php
$args = array(
'posts_per_page' => 1,
'post__in' => get_option( 'sticky_posts' ),
'ignore_sticky_posts' => 1,
);
query_posts($args);
if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
<?php
$thumb = get_post_thumbnail_id();
$img_url = wp_get_attachment_url( $thumb,'full' );
?>
<div id="toppost">
<div class="imagebg">
<a href="<?php the_permalink(); ?>">
<div class="topimage" href="<?php the_permalink(); ?>" style="background-image: linear-gradient(rgba(0, 0, 0, 0.5),rgba(0, 0, 0, 0.5)), url('<?php echo $img_url ?>')"></div>
</a>
<div id="overimg">
<div class="kategorias">
<?php the_category('', ', ', ''); ?>
</div>
<div class="toptitle">
<h2>
<a href="<?php the_permalink(); ?>">
<?php the_title(); /*3*/ ?>
</a>
</h2>
</div>
<div class="entrycontent">
<?php the_excerpt(); ?>
</div>
</div>
</div>
</div>
<?php endwhile; ?>
<?php wp_reset_query(); ?>
我在寻找解决方案,以显示第二个位置上的最后一篇文章只有当粘性是在第一个位置。在其他情况下,第二个位置消失。请显示更多代码。你是如何展示贴帖的?你有线圈吗?显示该循环,以及用于尝试获取最后一篇文章(第二个循环)的任何代码,您可以按日期或文章进行排序id@cale_b编辑,更多代码added@ThomasK好的,我可以按日期订购邮件,但当第一个循环上没有粘性邮件时,第二个位置不会消失。在该选项中,第一和第二个位置是相同的,最后一篇文章。请显示更多代码。你是如何展示贴帖的?你有线圈吗?显示该循环,以及用于尝试获取最后一篇文章(第二个循环)的任何代码,您可以按日期或文章进行排序id@cale_b编辑,更多代码added@ThomasK好的,我可以按日期订购邮件,但当第一个循环上没有粘性邮件时,第二个位置不会消失。在该选项中,第一个和第二个位置相同,最后一个位置。
<?php
$sticky = get_option( 'sticky_posts' );
$args=array(
'post_type' => 'post',
'post_status' => 'publish',
'caller_get_posts'=> 0,
'paged' => $paged,
'posts_per_page' => 1,
'post__not_in' => get_option( 'sticky_posts' ),
);
query_posts($args);
if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
<?php
$thumb = get_post_thumbnail_id();
$img_url = wp_get_attachment_url( $thumb,'full' );
?>
<div id="contentwrap">
<div id="topsticky">
<a href="<?php the_permalink(); ?>">
<div class="topimagesticky" href="<?php the_permalink(); ?>" style="background-image: url('<?php echo $img_url ?>')"></div>
</a>
<div id="overimgsticky">
<div class="kategoriasticky">
<?php the_category('', ', ', ''); ?>
</div>
<div class="toptitlesticky">
<h2>
<a href="<?php the_permalink(); ?>">
<?php the_title(); /*3*/ ?>
</a>
</h2>
</div>
<div class="entrycontent">
<p><?php the_excerpt(); ?></p>
</div>
</div>
</div>
</div>
<?php endwhile; ?>
<?php wp_reset_query(); ?>
$args=array(
'post_type' => 'post',
'post_status' => 'publish',
'paged' => $paged,
'posts_per_page' => 1,
'showposts' => 10,
'offset' => 1,
/* 'category__not_in' => 22, */
);`