Advertisement
roachdesign

Categories

May 26th, 2014
394
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.41 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. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement