Advertisement
roachdesign

Untitled

May 26th, 2014
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.66 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.  
  16. // Input Construction
  17.     // Grab each Category
  18.     $catch_variable = $category->term_id;
  19.     // Get the Category Description
  20.     $description_content = category_description($catch_variable);
  21.     // Limit amount of returned characters to break at the word level (not character)
  22.     $limit_excerpt = substr($description_content, 0, strpos($description_content, ' ', 260));
  23.     // Link to Category Archive, Excerpt I trimmed, & Second Link
  24.     $cleancode = $limit_excerpt . ' &hellip;' . ' <a href="' . get_category_link( $category->term_id ) . '" ' . '>' . ' Topic Overview &rarr;'.'</a>';
  25.  
  26. // Construction of Output
  27.     echo '<p class="topic-link-heading"><a href="' . get_category_link( $category->term_id ) . '" ' .
  28.     'id="topic-link"'  . '>' . $category->name.'</a> </p>';
  29.     $removephtml = substr($cleancode, 3);
  30.     echo '<p class="topic-list">' . $removephtml . '</p>';
  31.  
  32. // Need Help Here
  33.     $test = $category->term_id;
  34.     echo $test;
  35.     // Outputs the correct Category ID
  36.  
  37. // The Query
  38. query_posts( array('category__and'=>$test));
  39.  
  40. // The Loop
  41. while ( have_posts() ) : the_post();
  42.     echo '<li>';
  43.     the_title();
  44.     echo '</li>';
  45. endwhile;
  46. $relevant_posts = query_posts( $post_args );
  47. // Reset Query
  48. wp_reset_query();
  49. }
  50.  
  51. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement