<?php $sticky_posts = get_option('sticky_posts'); $args = array( 'post" />

置顶sticky文章和非置顶一起输出样例

<div class="news-grid">
                <?php 
                $sticky_posts = get_option('sticky_posts');

                $args = array(
                    'post_type'  => 'post',
                    'posts_per_page'  => 4,
                    'ignore_sticky_posts' => 0, // Ensures sticky posts are prioritized and moved to the front of the list
                    'orderby' => 'date',
                    'order' => 'DESC',

                );
                $query = new WP_Query($args);

                while ($query->have_posts()) {
                    $query->the_post(); 
                    $is_sticky = in_array(get_the_ID(), $sticky_posts);
                    if ($is_sticky) { ?>

                        <div class="news-card featured">
                            <div class="news-image">
                                <div class="news-image-placeholder"
                                    style="background: linear-gradient(135deg, #1D4E89 0%, #2a5f9e 100%);">
                                    <?php the_post_thumbnail(); ?>
                                </div>
                                <span class="news-badge featured-badge">Featured</span>
                            </div>
                            <div class="news-content">
                                <div class="news-meta">
                                    <span class="news-category"><?php echo get_the_category_list(', '); ?></span>
                                    <span class="news-date"><?php echo the_time(get_option('date_format')); ?></span>
                                </div>
                                <h3 class="news-title"><?php the_title(); ?></h3>
                                <p class="news-excerpt">
                                    <?php echo mb_strimwidth(strip_tags(get_the_content()), 0,100) ?>
                                </p>
                                <a href="<?php the_permalink(  ); ?>" class="news-link">Read Full Article →</a>
                            </div>
                        </div>
                        
                <?php    } else { ?>

                    <div class="news-card">
                    <div class="news-image">
                        <div class="news-image-placeholder"
                            style="background: linear-gradient(135deg, #333333 0%, #555555 100%);">
                            <?php the_post_thumbnail(); ?>
                        </div>
                        <span class="news-badge">Press Release</span>
                    </div>
                    <div class="news-content">
                        <div class="news-meta">
                            <span class="news-category"><?php echo get_the_category_list(); ?></span>
                            <span class="news-date"><?php echo the_time(get_option('date_format')); ?></span>
                        </div>
                        <h3 class="news-title"><?php the_title(); ?></h3>
                        <p class="news-excerpt">
                            <?php echo mb_strimwidth(strip_tags(get_the_content()), 0, 100) ?>
                        </p>
                        <a href="<?php the_permalink(  ); ?>" class="news-link">Read More →</a>
                    </div>
                </div>


              <?php  }

                    ?>

                    
             <?php   }

                 ?>
                
            </div>
×
置顶sticky文章和非置顶一起输出样例

置顶sticky文章和非置顶一起输出样例

<div class="news-...