コード例 #1
0
ファイル: functions.php プロジェクト: nil-vn/beautysite
function get_rankink_byname($name = '', $limit = 3)
{
    $result = get_categories(array('child_of' => $name));
    // list child categories
    $arrCat = array($name);
    foreach ($result as $key => $cat) {
        $arrCat[] = $cat->cat_ID;
        if (!in_array($cat->category_parent, $arrCat)) {
            $arrCat[] = $cat->category_parent;
        }
    }
    return get_rankink($arrCat, $limit);
}
コード例 #2
0
ファイル: index.php プロジェクト: nil-vn/beautysite
		<li class="ranknav04"><a href="#trouble">お悩み・効果</a></li>
		<li class="ranknav05"><a href="#component">成分・特徴</a></li>
		</ul>
		</header>


		<?php 
    $healthCat = get_category_by_slug('health');
    $cosmeCat = get_category_by_slug('cosme');
    $troubleCat = get_category_by_slug('trouble');
    $componentCat = get_category_by_slug('component');
    $category = array('', $healthCat->cat_ID, $cosmeCat->cat_ID, $troubleCat->cat_ID, $componentCat->cat_ID);
    foreach ($category as $key => $cat) {
        // get results
        if (empty($cat)) {
            $the_query = get_rankink();
        } else {
            $the_query = get_rankink_byname($cat);
        }
        // The Loop
        ?>
		<?php 
        if ($the_query->have_posts()) {
            ?>
			<div class="inner <?php 
            if ($key) {
                echo 'disnon';
            }
            ?>
">
			<ul>
コード例 #3
0
ファイル: popular_ranking.php プロジェクト: nil-vn/pan-pan
    /**
     * Front-end display of widget.
     *
     * @see WP_Widget::widget()
     *
     * @param array $args     Widget arguments.
     * @param array $instance Saved values from database.
     */
    public function widget($args, $instance)
    {
        $title = apply_filters('widget_title', $instance['title']);
        if (!empty($instance['all']) && $instance['all']) {
            $the_query = get_rankink(array(), $instance['limit']);
            $healthCat = get_category_by_slug('health');
            $cosmeCat = get_category_by_slug('cosme');
            $troubleCat = get_category_by_slug('trouble');
            $componentCat = get_category_by_slug('component');
        } else {
            $this_cat = get_query_var('cat');
            // get the category of this category archive page
            if (empty($this_cat)) {
                $category = get_the_category();
                if (is_single()) {
                    $arrCat = array();
                    foreach ($category as $key => $cat) {
                        $arrCat[] = $cat->cat_ID;
                        if (!in_array($cat->category_parent, $arrCat)) {
                            $arrCat[] = $cat->category_parent;
                        }
                    }
                    $the_query = get_rankink($arrCat, $instance['limit']);
                } else {
                    return;
                }
            } else {
                $result = get_categories(array('child_of' => $this_cat));
                // list child categories
                $arrCat = array($this_cat);
                foreach ($result as $key => $cat) {
                    $arrCat[] = $cat->cat_ID;
                    if (!in_array($cat->category_parent, $arrCat)) {
                        $arrCat[] = $cat->category_parent;
                    }
                }
                $the_query = get_rankink($arrCat, $instance['limit']);
            }
        }
        // echo $args['before_widget'];
        // if ( ! empty( $title ) )
        // 	echo $args['before_title'] . $title . $args['after_title'];
        // The Loop
        ?>
		<section class="entryRanking">
		<h1 class="sideTtl"><?php 
        echo $title;
        ?>
</h1>
		<?php 
        if ($the_query->have_posts()) {
            ?>
			<ol>
			<?php 
            $counter = 0;
            while ($the_query->have_posts()) {
                $the_query->the_post();
                $counter++;
                if (!empty($instance['all']) && $instance['all']) {
                    $category = get_the_category();
                    $color = "";
                    foreach ($category as $key => $cat) {
                        if ($cosmeCat->cat_ID == $cat->cat_ID || cat_is_ancestor_of($cosmeCat->cat_ID, $cat->cat_ID)) {
                            $color = "yellow";
                        } elseif ($troubleCat->cat_ID == $cat->cat_ID || cat_is_ancestor_of($troubleCat->cat_ID, $cat->cat_ID)) {
                            $color = "blue";
                        } elseif ($componentCat->cat_ID == $cat->cat_ID || cat_is_ancestor_of($componentCat->cat_ID, $cat->cat_ID)) {
                            $color = "purple";
                        }
                    }
                }
                // $count_key = 'post_views_count';
                // echo get_post_meta( get_the_ID() , $count_key , true) . '<br/>';
                // $countlog = get_post_meta( get_the_ID() , $count_key . 'log', true) ;
                // echo $countlog;
                ?>

				<li <?php 
                if ($counter <= 3) {
                    ?>
 class="rank<?php 
                    echo $counter;
                    ?>
" <?php 
                }
                ?>
 ><a href="<?php 
                the_permalink();
                ?>
">
				<div class="rank">No.<?php 
                echo $counter;
                ?>
</div>
				<?php 
                if ($counter <= 3) {
                    ?>
				<div class="pic"> <?php 
                    the_post_thumbnail('sidebar-thumb');
                    ?>
 </div>
				<?php 
                }
                ?>
				<div class="txt"><p class="ttl"><?php 
                the_title();
                ?>
</p>
					<?php 
                if (!empty($instance['all']) && $instance['all']) {
                    ?>
					<div class="tagMark <?php 
                    echo $color;
                    ?>
"><div><span><?php 
                    if (isset($category[0])) {
                        echo $category[0]->cat_name;
                    }
                    ?>
</span></div></div>
					<?php 
                }
                ?>
				</div>
				</a></li>
			<?php 
            }
            ?>
			</ol>
		<?php 
        }
        ?>
		</section>
<!--//.entryRanking-->
		<?php 
        wp_reset_query();
        // Restore global post data stomped by the_post().
        // echo $args['after_widget'];
    }