Advertisement
sarahn

issue-with-a-custom_post_type

Sep 14th, 2013
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.27 KB | None | 0 0
  1. <?php
  2. /*
  3. Template Name: Portfolio 2 columns
  4. */
  5.  
  6. get_header()
  7. ?>
  8.  
  9.  
  10. <div class="container contentwrapper">
  11.  
  12. <div class="sixteen columns alpha omega portpage">
  13.  
  14. <header><h1 class="headofpage"><?php the_title() ?></h1></header>
  15.  
  16. <?php
  17. echo showPortCategory(get_the_ID());
  18.  
  19. $args = array(
  20. 'post_type' => 'port',
  21. 'paged' => $paged,
  22. 'posts_per_page' => get_theme_option("portfolio_work_count"),
  23. );
  24.  
  25. if (isset($_GET['slug'])) {
  26. $args['tax_query'] = array(
  27. array(
  28. 'taxonomy' => 'portcat',
  29. 'field' => 'slug',
  30. 'terms' => $_GET['slug']
  31. )
  32. );
  33. }
  34.  
  35. $custom_query = new wp_query($args);
  36.  
  37. $tempi = 1;
  38.  
  39. echo "<div class='portrowed perline2'>";
  40.  
  41. while ( $custom_query->have_posts() ) : $custom_query->the_post();
  42. #We have:
  43. #get_permalink() - Full url to post;
  44. #get_the_title() - Post title;
  45. #get_the_content() - Post text;
  46. #get_post_time('U', true) - unix timestamp
  47.  
  48. $featured_image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'single-post-thumbnail');
  49.  
  50.  
  51. $taxonomies = get_taxonomies();
  52. $term_list = get_the_terms($key, $taxonomies);
  53.  
  54. $pf = get_post_format();
  55. if (empty($pf))
  56. $pf = "default";
  57.  
  58. $new_term_list = get_the_terms($post->ID, "portcat");
  59.  
  60. if (is_array($new_term_list)) {
  61. foreach ($new_term_list as $term) {
  62. $tempname = strtr($term->name, array(
  63. ' ' => '-',
  64. ));
  65. $echoallterm .= strtolower($tempname) . " ";
  66. $echoterm = $term->name;
  67. }
  68. }
  69. ?>
  70.  
  71. <div id="post-<?php the_ID() ?>" class="post block_shadow columns eight port2perline all <?php echo $echoallterm; ?>">
  72. <div class="thispost porttype preloader_container">
  73. <div class="post-type-cont">
  74.  
  75. <a href="<?php the_permalink() ?>" title="<?php the_title() ?>" rel="bookmark"><span class="type_<?php echo $pf; ?>"></span></a>
  76. </div>
  77. <div class="post-title-cont">
  78. <h2 class="post-title">
  79. <a href="<?php the_permalink() ?>" title="<?php the_title() ?>" rel="bookmark"><?php the_title() ?></a>
  80. </h2>
  81. <?php
  82. $content = get_the_content();
  83.  
  84. if (preg_match_all('#<h1>(.*)</h1>#i', $content, $matches)) {
  85. foreach ($matches[1] as $key => $val) {
  86. $$val = $matches[2][$key];
  87. }
  88. }
  89. ?>
  90. <h3><?php echo $val ?></h3>
  91. </div>
  92. <div class="post-content">
  93. <?php if (strlen($featured_image[0]) > 0) { ?><img alt='<?php echo get_the_title(); ?>' src='<?php echo TIMTHUMBURL; ?>?w=420&amp;h=230&amp;src=<?php echo $featured_image[0]; ?>'><?php } ?>
  94. <?php
  95. if (strlen($post->post_excerpt) > 0) {
  96. echo get_the_excerpt();
  97. }
  98. ?>
  99. </div>
  100. <a class="plus_btn" href="<?php the_permalink() ?>">click me</a>
  101. </div>
  102. <div class="clear"></div>
  103. </div><!-- .post -->
  104.  
  105. <?php
  106. unset($echoallterm);
  107.  
  108. endwhile;
  109. wp_reset_query();
  110. ?>
  111. </div><!-- // rowed -->
  112.  
  113. <?php get_pagination() ?>
  114. <div class="clear"></div>
  115. </div>
  116. </div>
  117. <div class="clear"></div>
  118.  
  119. <?php get_footer() ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement