<div class="container"> <div class="section-header"> <p c" />

创建sticky和非sticky文章全部在一起的查询

 <section class="news-section">
        <div class="container">
            <div class="section-header">
                <p class="section-label">Latest Updates</p>
                <h2 class="section-title">Industry News & Insights</h2>
                <p class="section-description">
                    Stay informed about our latest innovations, industry developments, and technical insights from our
                    engineering team.
                </p>
            </div>

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

                $args = array(
                    'post_type'  => 'post',
                    'posts_per_page'  => 4,
                    'ignore_sticky_posts'  => 0,
                    // order by default

                );
                $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>
            <div class="news-cta">
                <a href="<?php echo home_url('/news'); ?>" class="btn btn-secondary">View All News & Updates</a>
            </div>
        </div>
    </section>
×
创建sticky和非sticky文章全部在一起的查询

创建sticky和非sticky文章全部在一起的查询

<section class="n...