0

これが私が見つけて使用しようとしているスニペットです:

<?php
        $sticky = get_option( 'sticky_posts' );
        $most_recent_sticky_post = new WP_Query( array( 
            'post__in'            => $sticky, 
            'ignore_sticky_posts' => 1, 
            'orderby'             => date, 
            'posts_per_page'      => 1,
            'category'      => 'view'
        ) );
        ?>

        <?php while ( $most_recent_sticky_post->have_posts() ) :  $most_recent_sticky_post->the_post(); ?>
        <div class="imgFet">    
        <div > <?php the_post_thumbnail('homepage-thumb'); ?> </div>
        </div>
        <div class="textBoxcaption">        
            <div class="imgFeatureBoxImgText2">     
            <h2><?php the_title(); ?></h2>  
            <?php the_excerpt(); ?>
            <h3><a href=" <?php the_permalink(); ?>" > ReadMore</a></h3>
            </div>  
        </div>
    <?php endwhile; wp_reset_query(); ?>

カテゴリごとにスティッキーな投稿を戻すためだけに、これも試してみます:

<?php
            $sticky = get_option( 'sticky_posts' );
            rsort( $sticky );
            $sticky = array_slice( $sticky, 0, 1 );
            query_posts( array( 'post__in' => $sticky,'category' => 'watch','caller_get_posts' => 1 ) );
        ?>
        <?php while (have_posts()) : the_post(); ?>
        <div class="imgFet">    
        <div > <?php the_post_thumbnail('homepage-thumb'); ?> </div>
        </div>
        <div class="textBoxcaption">        
            <div class="imgFeatureBoxImgText2">     
            <h2><?php the_title(); ?></h2>  
            <?php the_excerpt(); ?>
            <h3><a href=" <?php the_permalink(); ?>" > ReadMore</a></h3>
            </div>  
        </div>
        <?php endwhile; ?>
    <?php wp_reset_query(); ?>

ウォッチとビューの2つのカテゴリがあり、投稿のチェックボックスでもチェックしました。

4

1 に答える 1

0

解決しました!これをarray

 'category__in'         => 'n'

nはあなたのカテゴリーの番号です

于 2013-06-23T15:32:23.570 に答える