<?php

/*
Template Name: Category

Used for: IE and Help Library OMS and Marketplace pages
*/
$category = get_category(get_query_var('cat'));
$categoryPosts = get_category_posts($category->slug);
get_header();
?>
<div class="jumbotron dkpurplebg">
  <div class="container-fluid">
    <div class="row">
      <div class="container">
        <div class="text-center topMargin90 xlgText"><?php 
echo $category->name;
?>
</div>
      </div>
    </div>
  </div>
</div>
<div class="container">
  <?php 
get_banner_search();
?>
  <p>&nbsp;</p>
</div>
<div class="container">
  <div class="row">
示例#2
0
<?php

$category_id = (int) $_GET['cat'];
$category_data = get_category($category_id);
echo '<h1 class="cat-title">' . $category_data['category_name'] . '</h1>';
$all_posts = get_category_posts($category_id);
foreach ($all_posts as $post) {
    ?>
		
		<div class="post">
			<a href="<?php 
    echo BASE_URL;
    ?>
?post_id=<?php 
    echo $post['post_id'];
    ?>
">
				<h2><?php 
    echo $post['post_title'];
    ?>
</h2>
			</a>
			<div class="post-meta">
				<?php 
    $user = get_user($post['user_id']);
    ?>
				<?php 
    echo $post['publish_date'];
    ?>
 | <?php 
    echo get_user_name_by_id($post['user_id']);
    <div class="row">
        <div class="medium-12 columns">
           <hr>
        </div>
    </div>

    <section class="body">
        <div class="row">
            <!-- RECENT ARTICLES -->
            <div class="medium-8 columns">
                <div class="recent-articles">
                    <a href="#"><h4>Recent Articles</h4></a>
                    
                    <?php 
// Get all recent posts not in the Featured category.
$recent_posts = get_category_posts(array('category__not_in' => $featured_term_id));
?>
                    <ul>
                        <?php 
while ($featured_posts->have_posts()) {
    $featured_posts->the_post();
    ?>

                            <li class="recent-articles-item">
                                <div class="thumbnail">
                                    <?php 
    the_post_thumbnail('thumbnail');
    ?>
                                </div>
                                <a href="<?php 
    the_permalink();
</h1> 

          

          <div class="entry-content">

            <?php 
        the_content();
        ?>
            
          </div>

          <?php 
        $cat_slug = get_post_meta($post->ID, 'show-posts-from-category', true);
        if ($cat_slug) {
            echo get_category_posts(get_post_meta($post->ID, 'show-posts-from-category', true));
        }
        ?>

         </div><!-- #post-## -->
      <?php 
    }
}
// end of the loop.
?>
    </div> 
    <?php 
include TEMPLATEPATH . '/includes/elections_sidebar.php';
?>
  </div>
</div>
$categories = get_terms('category', array('hide_empty' => false, 'exclude' => array($featured_term_id, $uncategorized_term_id, $sponsored_term_id)));
?>

<aside class="left-off-canvas-menu">
    <!-- NAV -->
    <form class='search' method='post'><input type='hidden' name='form-name' value='form 1' />
        <div class="row">
            <div class="medium-12 columns">
                <input type="search" placeholder="Search The Open Standard">
            </div>
        </div>
    </form>
    <ul class="nav">
        <?php 
foreach ($categories as $category) {
    $category_posts = get_category_posts(array('cat' => $category->term_id, 'posts_per_page' => 3));
    ?>
            <li class="nav-item">
                <div class="topics-tag-normal <?php 
    echo $category->slug;
    ?>
">
                    <a href="<?php 
    echo get_category_link($category->term_id);
    ?>
"><?php 
    echo $category->name;
    ?>
</a>
                </div>
                <ul class="nav-item-list">