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

问题描述

  • 当我的一篇博客文章是“坚持到博客顶部”时,它不应显示在我最新的文章轮播中。因为它会出现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.JdbcOdbc...