好啊代码可能仍然有点站不住脚,但以下是我的想法(仍然没有发布旧的、甚至更糟糕的PHP;抱歉,让投票人失望),以防其他人可能使用它或可以改进它。
<section class="column first">
<h2>What\'s New</h2>
<?php
$sticky = get_option( \'sticky_posts\' );
$args = array(
\'category_name\' => \'news\',
\'post__in\' => $sticky,
);
query_posts( $args ); while (have_posts()) : the_post();
{ ?>
<h3><?php the_title(); ?></h3>
<?php the_content(); ?>
<?php } endwhile; wp_reset_query(); ?>
</section>
<section class="column middle">
<h2>Country Projects</h2>
<?php
$sticky = get_option( \'sticky_posts\' );
$args = array(
\'category_name\' => \'projects\',
\'post__in\' => $sticky,
);
query_posts( $args ); while (have_posts()) : the_post();
{ ?>
<h3><?php the_title(); ?></h3>
<?php the_content(); ?>
<?php } endwhile; wp_reset_query(); ?>
</section>
<section class="column last">
<h2>Featured Publications</h2>
<?php
$sticky = get_option( \'sticky_posts\' );
$args = array(
\'category_name\' => \'publications\', //This is the parent category, no need for using the cat ID this way.
\'post__in\' => $sticky,
);
query_posts( $args ); while (have_posts()) : the_post();
{ ?>
<h3><?php the_title(); ?></h3>
<?php the_content(); ?>
<?php } endwhile; wp_reset_query(); ?>
</section>
请随时对此进行改进或评论如何优化和/或我的方法的利弊。