Guest User

Untitled

a guest
Mar 18th, 2016
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.55 KB | None | 0 0
  1. <?php
  2. /* Template Name: Product Category */
  3.  
  4.  
  5. get_header();
  6.  
  7. td_global::$current_template = 'page-title-sidebar';
  8. //set the template id, used to get the template specific settings
  9. $template_id = 'page';
  10.  
  11.  
  12. $loop_sidebar_position = td_util::get_option('tds_' . $template_id . '_sidebar_pos'); //sidebar right is default (empty)
  13.  
  14.  
  15. //read the custom single post settings - this setting overids all of them
  16. $td_page = get_post_meta($post->ID, 'td_page', true);
  17. if (!empty($td_page['td_sidebar_position'])) {
  18. $loop_sidebar_position = $td_page['td_sidebar_position'];
  19. }
  20.  
  21. // sidebar position used to align the breadcrumb on sidebar left + sidebar first on mobile issue
  22. $td_sidebar_position = '';
  23. if($loop_sidebar_position == 'sidebar_left') {
  24. $td_sidebar_position = 'td-sidebar-left';
  25. }
  26.  
  27.  
  28. /**
  29. * detect the page builder
  30. */
  31. $td_use_page_builder = false;
  32. if (method_exists('WPBMap', 'getShortCodes')) {
  33. $td_page_builder_short_codes = array_keys(WPBMap::getShortCodes());
  34. if (td_util::strpos_array($post->post_content, $td_page_builder_short_codes) === true) {
  35. $td_use_page_builder = true;
  36. }
  37. }
  38.  
  39.  
  40.  
  41.  
  42. //no page builder detected, we load a default page template with sidebar / no sidebar
  43. ?>
  44. <div class="td-main-content-wrap">
  45. <div class="td-container <?php echo $td_sidebar_position; ?>">
  46. <div class="td-crumb-container">
  47. <?php echo td_page_generator::get_page_breadcrumbs(get_the_title()); ?>
  48. </div>
  49. <div class="td-pb-row">
  50. <?php
  51. switch ($loop_sidebar_position) {
  52. default:
  53. ?>
  54. <div class="td-pb-span8 td-main-content" role="main" itemscope="itemscope" itemprop="mainContentOfPage" itemtype="<?php echo td_global::$http_or_https?>://schema.org/CreativeWork">
  55. <div class="td-ss-main-content">
  56. <?php
  57. if (have_posts()) {
  58. while ( have_posts() ) : the_post();
  59. ?>
  60. <div class="td-page-header">
  61. <h1 itemprop="name" class="entry-title td-page-title">
  62. <span><?php the_title() ?></span>
  63. </h1>
  64. </div>
  65. <div class="td-pb-padding-side td-page-content">
  66. <?php
  67. the_content();
  68. endwhile;//end loop
  69. }
  70. ?>
  71. </div>
  72. </div>
  73. </div>
  74. <div class="td-pb-span4 td-main-sidebar" role="complementary">
  75. <div class="td-ss-main-sidebar">
  76. <?php get_sidebar(); ?>
  77. </div>
  78. </div>
  79. <?php
  80. break;
  81.  
  82. case 'sidebar_left':
  83. ?>
  84. <div class="td-pb-span8 td-main-content <?php echo $td_sidebar_position; ?>-content" role="main" itemscope="itemscope" itemprop="mainContentOfPage" itemtype="<?php echo td_global::$http_or_https?>://schema.org/CreativeWork">
  85. <div class="td-ss-main-content">
  86. <?php
  87.  
  88. if (have_posts()) {
  89. while ( have_posts() ) : the_post();
  90. ?>
  91. <div class="td-page-header">
  92. <h1 itemprop="name" class="entry-title td-page-title">
  93. <span><?php the_title() ?></span>
  94. </h1>
  95. </div>
  96. <div class="td-pb-padding-side td-page-content">
  97. <?php
  98. the_content();
  99. endwhile; //end loop
  100. }
  101. ?>
  102. </div>
  103. </div>
  104. </div>
  105. <div class="td-pb-span4 td-main-sidebar" role="complementary">
  106. <div class="td-ss-main-sidebar">
  107. <?php get_sidebar(); ?>
  108. </div>
  109. </div>
  110. <?php
  111. break;
  112.  
  113. case 'no_sidebar':
  114. ?>
  115. <div class="td-pb-span12 td-main-content" role="main" itemscope="itemscope" itemprop="mainContentOfPage" itemtype="<?php echo td_global::$http_or_https?>://schema.org/CreativeWork">
  116. <div class="td-ss-main-content">
  117. <?php
  118. if (have_posts()) {
  119. while ( have_posts() ) : the_post();
  120. ?>
  121. <div class="td-page-header">
  122. <h1 itemprop="name" class="entry-title td-page-title">
  123. <span><?php the_title() ?></span>
  124. </h1>
  125. </div>
  126. <div class="td-pb-padding-side td-page-content">
  127. <?php
  128. the_content();
  129. endwhile; //end loop
  130. }
  131. ?>
  132. </div>
  133. </div>
  134. </div>
  135. <?php
  136. break;
  137. }
  138. ?>
  139. </div> <!-- /.td-pb-row -->
  140. </div> <!-- /.td-container -->
  141. </div> <!-- /.td-main-content-wrap -->
  142.  
  143. <?php
  144.  
  145.  
  146.  
  147.  
  148. get_footer();
  149. ?>
  150. `
  151.  
  152. I tried to put the featured header image just above the .td-main-content-wrap class. Here's the code I was using but it wasn't loading the image for some reason. Not sure why.
  153.  
  154. `
  155.  
  156. <?php
  157. $thumb = get_post_thumbnail_id();
  158. $img_url = wp_get_attachment_url( $thumb,'full' );
  159. ?>
  160. <div class="postfeat container">
  161. <div class="imghoverclass img-margin-center">
  162. <img />" alt="<?php the_title(); ?>" />
  163. </div>
  164. </div>
  165.  
  166. `
  167.  
  168. The final HTML output is as such:
  169.  
  170. `
  171. <div class="postfeat container">
  172. <div class="imghoverclass img-margin-center">
  173. <img src="" alt="BEE70" />
  174. </div>
  175. </div>
Advertisement
Add Comment
Please, Sign In to add comment