微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何从我最近的博客文章中删除“坚持到博客顶部”的帖子?

如何解决如何从我最近的博客文章中删除“坚持到博客顶部”的帖子?

  • 当我的一篇博客文章是“坚持到博客顶部”时,它不应显示在我最新的文章轮播中。因为它会出现2次,1次在“贴到博客顶部”,1次出现在“最新帖子”中。因此,如果它是“坚持到博客的顶部”,请将其从最新帖子中删除。我怎么做?但是当博客文章不是“坚持到博客顶部”时,它应该显示在最新的文章中:)

  • 是否也可以在 wordpress 后端中执行此操作?当我已经有一篇博客文章是“坚持到博客的顶部”并且我又写了另一篇博客文章(选中)““坚持到博客的顶部”作为另一篇博客文章时,它应该弹出消息并说“你已经有一个贴到博客顶部”,你想删除旧的,让这个成为新的“贴到博客的顶部 “?所以它会让你知道你有超过 1 个“坚持到博客的顶部”被选中。类似的东西。

<!-- Stick to the top of the blog -->
    <?PHP
    $sticky = get_option( 'sticky_posts' );
        $args = array(
        'posts_per_page' => 1,/* how many post you need to display */
        'offset' => 0,'orderby' => 'post_date','order' => 'DESC','post_type' => 'post',/* your post type name */
        'post_status' => 'publish','post__in'  => $sticky,'ignore_sticky_posts' => 1
    );

    $query = new WP_Query($args);
    if ($query->have_posts()) :
        while ($query->have_posts()) : $query->the_post();
            
            get_template_part( 'template-parts/content',get_post_format() );
            
        endwhile;
    endif;
    ?>
    <!-- /Stick to the top of the blog -->
    
    
    <!-- Latest Post -->
    <div class="posts-items latest-posts">
        <section class="row">
            <h2 class="title slider-title">
                <a href="<?PHP echo get_permalink( get_page_by_path( 'recipes' ) ) ?>">
                <?PHP _e('Latest Recipes ','wpcrumbs'); ?>
                    <img src="<?PHP bloginfo('template_url')?>/icon/right-arrow.svg">
                </a>
            </h2>

            <div class="owl-carousel latest-posts owl-theme">

            <?PHP 
                $args = array(
                    'posts_per_page' => 5,'ignore_sticky_posts' => 1
                );

                // Define our WP Query Parameters
                $the_query = new WP_Query( $args ); ?>
                  
                <?PHP 
                // Start our WP Query
                while ($the_query -> have_posts()) : $the_query -> the_post(); 
                // display the Post Title with Hyperlink
            ?>



            <article class="posts-content">
                <a href="<?PHP the_permalink() ?>">
                    <div class="thumb">
                    <?PHP if (has_post_thumbnail()) { ?>
                        <?PHP the_post_thumbnail('post-thumbnail',array('alt' => the_title_attribute(array('echo' => false)))); ?>
                        
                    <?PHP } else { 
                        waisiechef_thumbnail_default();
                    } ?>
                    </div>

                    <?PHP the_category(); ?>
                   
                    <h2><?PHP the_title(); ?></h2>
                </a>
            </article>
        
            <?PHP 
            // Repeat the process and reset once it hits the limit
            endwhile;
            wp_reset_postdata();
            ?>

            </div>

        </section>
    </div>
    <!-- /Latest Post -->

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?