Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Template Name: var_dump_theme
- */ ?>
- <?php get_header(); ?><div>
- <?php
- // The Query for the variables
- // Customize query as wanted
- query_posts('posts_per_page=5&orderby=ID&order=ASC');
- //The Loop with the variables
- if ( have_posts() ) : while ( have_posts() ) : the_post();
- // Post id
- $id = get_the_ID();
- // Post date
- $date = the_date( '', '', '', False );
- // Post title
- $title = $post->post_title;
- // Post url
- $post_url = $post->post_name;
- // Parent category
- foreach (get_the_category() as $cat) {
- $parent = get_category($cat->category_parent);
- $parent_name = $parent->cat_name;
- $parent_url = $parent->slug;
- }
- $parent_category = $parent_name;
- $parent_category_url = $parent_url;
- // Show custom taxonomy and terms for a specified parent category (one for each custom taxonomy)
- if ( in_category(add_parent_category number) || post_is_in_descendant_category(add_parent_category_number)) {
- $terms = get_the_terms($post->ID, 'your_custom_taxonomy');
- foreach ($terms as $taxitem) {
- $taxonomy = $taxitem->taxonomy;
- $term_name = $taxitem->name . ',';
- $term_url = $taxitem->slug . ',';
- }
- $custom_taxonomy_url = $taxonomy;
- $custom_taxonomy_term_name = $term_name;
- $custom_taxonomy_term_url = $term_url;
- }
- // Show custom taxonomy and terms for a specified parent category (one for each custom taxonomy)
- if ( in_category(add_second_parent_category number) || post_is_in_descendant_category(add_parent_category number)) {
- $terms = get_the_terms($post->ID, 'your_custom_taxonomy');
- foreach ($terms as $taxindex => $taxitem) {
- $taxonomy = $taxitem->taxonomy;
- $term_name = $taxitem->name;
- $term_url = $taxitem->slug;
- }
- $custom_taxonomy_url = $taxonomy;
- $custom_taxonomy_term_name = $term_name;
- $custom_taxonomy_term_url = $term_url;
- }
- // Comment count
- $comment_count = $post->comment_count;
- // Post excerpt
- $excerpt = $post->post_excerpt;
- // Post content
- $story = $post->post_content;
- ?>
- <?php
- // Display on screen
- // Post title
- $display .= '<h2>Title:<h2>';
- $display .= '<p>' . $title . '<p>';
- // Post slug
- $display .= '<h2>Post url:<h2>';
- $display .= '<p>' . $post_url . '<p>';
- // Post ID
- $display .= '<h2>ID:<h2>';
- $display .= '<p>' . $id . '<p>';
- // Post Date
- $display .= '<h2>Date:<h2>';
- $display .= '<p>' . $date . '<p>';
- // Parent category
- $display .= '<h2>Parent category:<h2>';
- $display .= '<p>' . $parent_category . '<p>';
- // Parent category url
- $display .= '<h2>Parent category url:<h2>';
- $display .= '<p>' . $parent_category_url . '<p>';
- // Taxonomy url
- $display .= '<h2>Taxonomy url:<h2>';
- $display .= '<p>' . $custom_taxonomy_url . '<p>';
- // Taxonomy term
- $display .= '<h2>Term(s):<h2>';
- $display .= '<p>' . $custom_taxonomy_term_name . '<p>';
- // Taxonomy term url
- $display .= '<h2>Term url(s):<h2>';
- $display .= '<p>' . $custom_taxonomy_term_url . '<p>';
- // Comment count
- $display .= '<h2>Comment count:<h2>';
- $display .= '<p>' . $comment_count . '<p>';
- // Excerpt post
- $display .= '<h2>Excerpt:<h2>';
- $display .= '<p>' . $excerpt . '<p>';
- // Post content
- $display .= '<h2>Story:<h2>';
- $display .= '<p>' . $story . '<p>';
- print $display;
- ?>
- <?php
- // stop looping
- endwhile; else:
- echo 'nothing found'; // no records found for the query
- endif;
- //Reset Query
- wp_reset_query();
- ?>
- </div>
- <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement