Advertisement
roachdesign

Untitled

May 26th, 2014
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.04 KB | None | 0 0
  1. <?php
  2. // Call Wordpress Function get_categories ();
  3. $args = array(
  4.     'type'                     => 'post',
  5.     'orderby'                  => 'name',
  6.     'hide_empty'               => 0,
  7.     'hierarchical'             => 1,
  8.     'exclude'                  => '6, 1,16,17,18,19,20,15',
  9.     'taxonomy'                 => 'category',
  10.     'pad_counts'               => false
  11.   );
  12. $categories = get_categories($args);
  13.  
  14. foreach($categories as $category) {
  15. // Input Construction
  16.     // Grab each Category
  17.     $catch_variable = $category->term_id;
  18.     // Get the Category Description
  19.     $description_content = category_description($catch_variable);
  20.     // Limit amount of returned characters to break at the word level (not character)
  21.     $limit_excerpt = substr($description_content, 0, strpos($description_content, ' ', 260));
  22.     // Link to Category Archive, Excerpt I trimmed, & Second Link
  23.     $cleancode = $limit_excerpt . ' &hellip;' . ' <a href="' . get_category_link( $category->term_id ) . '" ' . '>' . ' Topic Overview &rarr;'.'</a>';
  24.  
  25. // Construction of Output
  26.     echo '<p class="topic-link-heading"><a href="' . get_category_link( $category->term_id ) . '" ' .
  27.     'id="topic-link"'  . '>' . $category->name.'</a> </p>';
  28.     $removephtml = substr($cleancode, 3);
  29.     echo '<p class="topic-list">' . $removephtml . '</p>';
  30.  
  31. // Need Help Here
  32.     $category = $category->term_id;
  33.     echo $category;
  34.     // Outputs the correct Category ID
  35.  
  36.  $post_args = array(
  37. 'posts_per_page'   => 5,
  38. 'offset'           => 0,
  39. 'category'         => '$category',
  40. 'orderby'          => 'post_date',
  41. 'order'            => 'DESC',
  42. 'include'          => '',
  43. 'exclude'          => '',
  44. 'meta_key'         => '',
  45. 'meta_value'       => '',
  46. 'post_type'        => 'post',
  47. 'post_mime_type'   => '',
  48. 'post_parent'      => '',
  49. 'post_status'      => 'publish',
  50. 'suppress_filters' => true );
  51.  
  52. // The Query
  53. query_posts( $post_args );
  54.  
  55. // The Loop
  56. while ( have_posts() ) : the_post();
  57.     echo '<li>';
  58.     the_title();
  59.     echo '</li>';
  60. endwhile;
  61.  
  62. // Reset Query
  63. wp_reset_query();
  64.  
  65.  
  66. }
  67. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement