Advertisement
Guest User

Untitled

a guest
May 26th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.50 KB | None | 0 0
  1. <?php
  2.  /*
  3. Template Name: var_dump_theme
  4. */ ?>
  5.  
  6. <?php  get_header(); ?><div>
  7.  
  8. <?php
  9.    
  10. // The Query for the variables
  11. // Customize query as wanted
  12.  
  13.     query_posts('posts_per_page=5&orderby=ID&order=ASC');
  14.    
  15. //The Loop with the variables
  16.    
  17.     if ( have_posts() ) : while ( have_posts() ) : the_post();
  18.  
  19. // Post id
  20.  
  21.     $id =  get_the_ID();
  22.    
  23. // Post date
  24.  
  25.     $date = the_date( '', '', '', False );
  26.    
  27. // Post title
  28.  
  29.     $title =  $post->post_title;
  30.    
  31. // Post url
  32.  
  33.     $post_url = $post->post_name;
  34.    
  35. // Parent category
  36.  
  37.     foreach (get_the_category() as $cat) {
  38.         $parent = get_category($cat->category_parent);
  39.         $parent_name = $parent->cat_name;
  40.         $parent_url =  $parent->slug;
  41.     }
  42.  
  43.     $parent_category =  $parent_name;
  44.     $parent_category_url = $parent_url;
  45.    
  46. // Show custom taxonomy and terms for a specified parent category (one for each custom taxonomy)
  47.    
  48.     if ( in_category(add_parent_category number) || post_is_in_descendant_category(add_parent_category_number)) {
  49.         $terms = get_the_terms($post->ID, 'your_custom_taxonomy');
  50.         foreach ($terms as $taxitem) {
  51.             $taxonomy = $taxitem->taxonomy;
  52.             $term_name = $taxitem->name . ',';
  53.             $term_url  = $taxitem->slug . ',';
  54.         }
  55.  
  56.         $custom_taxonomy_url =  $taxonomy;
  57.         $custom_taxonomy_term_name = $term_name;
  58.         $custom_taxonomy_term_url = $term_url;
  59.     }
  60.  
  61. // Show custom taxonomy and terms for a specified parent category (one for each custom taxonomy)
  62.    
  63.     if ( in_category(add_second_parent_category number) || post_is_in_descendant_category(add_parent_category number)) {
  64.         $terms = get_the_terms($post->ID, 'your_custom_taxonomy');
  65.         foreach ($terms as $taxindex => $taxitem) {
  66.             $taxonomy = $taxitem->taxonomy;
  67.             $term_name = $taxitem->name;
  68.             $term_url  = $taxitem->slug;
  69.         }
  70.  
  71.         $custom_taxonomy_url =  $taxonomy;
  72.         $custom_taxonomy_term_name = $term_name;
  73.         $custom_taxonomy_term_url = $term_url;
  74.     }
  75.  
  76. // Comment count
  77.  
  78.     $comment_count = $post->comment_count;
  79.  
  80. // Post excerpt
  81.  
  82.     $excerpt = $post->post_excerpt;
  83.  
  84. // Post content
  85.  
  86.     $story = $post->post_content;
  87.     ?>
  88.  
  89. <?php
  90.  
  91.     // Display on screen
  92.    
  93. // Post title
  94.  
  95.     $display .= '<h2>Title:<h2>';
  96.     $display .= '<p>' . $title . '<p>';
  97.    
  98. // Post slug
  99.  
  100.     $display .= '<h2>Post url:<h2>';
  101.     $display .= '<p>' .  $post_url . '<p>';
  102.    
  103. // Post ID
  104.  
  105.     $display .= '<h2>ID:<h2>';
  106.     $display .= '<p>' .  $id . '<p>';
  107.    
  108. // Post Date
  109.  
  110.     $display .= '<h2>Date:<h2>';
  111.     $display .= '<p>' .  $date . '<p>';
  112.    
  113. // Parent category
  114.  
  115.     $display .= '<h2>Parent category:<h2>';
  116.     $display .= '<p>' . $parent_category . '<p>';
  117.    
  118. // Parent category url
  119.  
  120.     $display .= '<h2>Parent category url:<h2>';
  121.     $display .= '<p>' . $parent_category_url . '<p>';
  122.    
  123. // Taxonomy url
  124.  
  125.     $display .= '<h2>Taxonomy url:<h2>';
  126.     $display .= '<p>' . $custom_taxonomy_url . '<p>';
  127.    
  128. // Taxonomy term
  129.  
  130.     $display .= '<h2>Term(s):<h2>';
  131.     $display .= '<p>' . $custom_taxonomy_term_name . '<p>';
  132.    
  133. // Taxonomy term url
  134.  
  135.     $display .= '<h2>Term url(s):<h2>';
  136.     $display .= '<p>' . $custom_taxonomy_term_url . '<p>';
  137.    
  138. // Comment count
  139.  
  140.     $display .= '<h2>Comment count:<h2>';
  141.     $display .= '<p>' . $comment_count . '<p>';
  142.    
  143. // Excerpt post
  144.  
  145.     $display .= '<h2>Excerpt:<h2>';
  146.     $display .= '<p>' . $excerpt . '<p>';
  147.    
  148. // Post content
  149.  
  150.     $display .= '<h2>Story:<h2>';
  151.     $display .= '<p>' . $story . '<p>';
  152.     print $display;
  153.     ?>
  154. <?php
  155.    
  156. // stop looping
  157.  
  158.     endwhile; else:
  159.     echo 'nothing found'; // no records found for the query
  160.     endif;
  161.  
  162. //Reset Query
  163.     wp_reset_query();
  164.  
  165.     ?>
  166.  
  167. </div>
  168.  
  169. <?php  get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement