News Update :
Home » » Make a request categories

Make a request categories

By: Unknown on Saturday, 21 February 2015 | 11:36

Sometimes we want to query category and not articles. Here's how to handle this type of request.
 









<?php
                //list terms in a given taxonomy using wp_list_categories  (also useful as a widget)
                $orderby = 'name';
                $show_count = 0; // 1 for yes, 0 for no
                $pad_counts = 0; // 1 for yes, 0 for no
                $hierarchical = 1; // 1 for yes, 0 for no
                $taxonomy = 'ste-adele';
                $title = '';

                $args = array(
                   
                    'post_type' => 'membre',
                  'orderby' => $orderby,
                  'show_count' => $show_count,
                  'pad_counts' => $pad_counts,
                  'hierarchical' => $hierarchical,
                  'taxonomy' => $taxonomy,
                  'title_li' => $title
                );
                ?>
                <ul>
                <?php
                wp_list_categories($args);
                ?>


$args = array(
                    'type'                     => 'membre',
                    'child_of'                 => 0,
                    'parent'                   => '832',
                    'orderby'                  => 'name',
                    'order'                    => 'ASC',
                    'hide_empty'               => 1,
                    'hierarchical'             => 1,
                    'exclude'                  => '',
                    'include'                  => '',
                    'number'                   => '',
                    'taxonomy'                 => 'ste-adele',
                    'pad_counts'               => false

                );



$args=array(
  'orderby' => 'name',
  //'parent' => '5',
  'order' => 'ASC',
  'hide_empty' => '0'
  );
$categories=get_categories($args);
  foreach($categories as $category) {
    $output = '
   <div class="' . $category->slug . '">
                <h3>' . $category->name . '</h3>
                <img src="' . get_bloginfo( 'template_url' ) . '/images/categories/' . $category->slug . '_feature.jpg" alt="' . $category->name .'" />
                <p>' . $category->description .'</p>
                <h4>Explore</h4>
                <ul>';

                global $post;
                $args = array( 'numberposts' => 3, 'category' => $category->term_id );
$myposts = get_posts( $args );
foreach( $myposts as $post ) :  setup_postdata($post);
        $output .=  '<li><a href="' . get_permalink($post->ID) . '">' . get_the_title($post->ID) . '</a></li>';
endforeach;
        $output .=  '
                <li><a href="' . get_category_link( $category->term_id ) . '">More...</a></li>
                </ul>
                <br />
                </div>
   ';
echo $output;
}
 
Contact Us | Privacy policy | Term of use | Advertise with Us | Site map
Copyright © 2011. Blogging Brain . All Rights Reserved.
Design Template by Blogging Brain | | Powered by Blogger