如何避免多次重复发帖

时间:2019-09-05 09:57:46

标签: php wordpress

我对Wordpress主题开发还很陌生,发现自己在编码方面陷入了困境。

我创建了两个循环,其中一个循环只有1个帖子,并且用更大的图像设置了样式;在第二个循环中,我尝试获取其余的帖子,但是我遇到了一些主要问题。

  1. 在第二个循环中,也出现了第一个循环的帖子,我想避免重复。

  2. 当我转到第2页或更高页面时,也出现了来自第一个循环的帖子,我希望它仅出现在根页面上。

下面是我的代码。

第一次循环

<?php          
    $bigi = array(
        'posts_per_page'      => '1',
        'post__not_in'        => get_option( 'sticky_posts' ),
    );
    $restp = new WP_Query($bigi);
?>

<!-- Loop started for bigimage single  post -->
<?php if($restp->have_posts()) { ?>
    <?php while($restp->have_posts()) { ?>
        <?php $restp->the_post();

             $post_id = get_the_ID(); ?>

            <?php get_template_part('template/post/bigimage'); ?>

    <?php } ?>
<?php } ?> <!-- Loop ended for rest of the  post -->
<?php wp_reset_postdata(); ?>

第二循环

<?php 
    $ropl= new WP_Query(array (
        'post__not_in'  =>  get_option('sticky_posts'),
        'paged' =>  $paged,
    )); 
 ?>
<!-- Loop started for bigimage single  post -->
<?php if($ropl->have_posts()) { ?>
    <?php while($ropl->have_posts()) { ?>
        <?php $ropl->the_post(); ?>


        <?php get_template_part('template/post/rop'); ?>

    <?php } ?>
<?php } ?> <!-- Loop ended for rest of the  post -->
<?php wp_reset_postdata(); ?>

1 个答案:

答案 0 :(得分:0)

这应该可行。根据您的要求更改查询。

        if ARWorldTrackingConfiguration.isSupported {

            let configuration = ARWorldTrackingConfiguration()             // 6DOF
            if #available(iOS 11.3, *) {
                configuration.planeDetection = [.horizontal, .vertical]
            } else {
                // Fallback on earlier versions
            }
            sceneView.session.run(configuration)

        } else {

            let configuration = AROrientationTrackingConfiguration()       // 3DOF
            sceneView.session.run(configuration)
            print("This chipset does not meet the minimum requirements.")
        }