PageRenderTime 27ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/index.php

https://gitlab.com/Almamun444/Octa
PHP | 338 lines | 241 code | 79 blank | 18 comment | 25 complexity | 8bea1b625d2ff6c9f182b2820ada33b4 MD5 | raw file
  1. <?php
  2. /**
  3. * The main template file.
  4. *
  5. * This is the most generic template file in a WordPress theme
  6. * and one of the two required files for a theme (the other being style.css).
  7. * It is used to display a page when nothing more specific matches a query.
  8. * E.g., it puts together the home page when no home.php file exists.
  9. *
  10. * @link https://codex.wordpress.org/Template_Hierarchy
  11. *
  12. * @package octa
  13. */
  14. // Sidebar
  15. $widget_position = cs_get_option('tx_sidebar_position');
  16. // Slider
  17. $default_slider_position = cs_get_option('all_slider_layout');
  18. $slider_position = $default_slider_position['slider_layout'];
  19. // slider_groups
  20. $slider_groups = $default_slider_position['home_slider'];
  21. // sticky post count
  22. $slider_sticky = $default_slider_position['sticky_slider'];
  23. // Slider title transform
  24. $title_transform = cs_get_option('slider_link_transform');
  25. $args = array(
  26. 'posts_per_page' =>$slider_sticky ,
  27. 'post__in' => get_option( 'sticky_posts' ),
  28. 'category_name' => 'fashion',
  29. 'ignore_sticky_posts' => 1
  30. );
  31. $query = new WP_Query( $args );
  32. $query_args = array(
  33. 'order' => 'DESC',
  34. 'orderby' => 'orderby',
  35. 'posts_per_page' => 1,
  36. 'ignore_sticky_posts' => 1
  37. );
  38. get_header();
  39. ?>
  40. <?php if(is_front_page()): ?>
  41. <?php if($slider_position=='sticky') :?>
  42. <div id="octa-post-slider" class="carousel slide" data-ride="carousel">
  43. <!-- Wrapper for slides -->
  44. <div class="carousel-inner" role="listbox">
  45. <?php
  46. $i=0;
  47. while($query->have_posts()) : $query->the_post();
  48. $active = ($i == 0 ? 'active' : '');
  49. ?>
  50. <div class="item <?php echo $active;?>">
  51. <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a>
  52. <div class="carousel-caption">
  53. <?php if(get_the_time()):?>
  54. <!-- Post date time -->
  55. <span><a href="<?php the_permalink();?>"><?php the_time('F j, Y'); ?></a></span>
  56. <?php endif;?>
  57. <h1 class="slider-title <?php echo $title_transform; ?>"><a href="<?php the_permalink();?>"><?php echo wp_trim_words( get_the_title(),5, ''); ?></a></h1>
  58. <p class="slider-content"><?php echo wp_trim_words( get_the_excerpt(),10, ''); // post title ?></p>
  59. <a class="btn btn-border" href="<?php the_permalink();?>">Read More</a>
  60. </div>
  61. </div>
  62. <?php $i++; endwhile; wp_reset_query(); ?>
  63. </div>
  64. <!-- Controls -->
  65. <a class="left-control carousel-control" href="#octa-post-slider" role="button" data-slide="prev">
  66. <span class="icon-left ion-ios-arrow-thin-left" aria-hidden="true"></span>
  67. <span class="sr-only"><?php esc_html_e('Previous', 'octa');?></span>
  68. </a>
  69. <a class="right-control carousel-control" href="#octa-post-slider"role="button" data-slide="next">
  70. <span class="icon-right ion-ios-arrow-thin-right" aria-hidden="true"></span>
  71. <span class="sr-only"><?php esc_html_e('Next', 'octa');?></span>
  72. </a>
  73. </div>
  74. <?php else: ?>
  75. <div id="octa-image-slider" class="carousel">
  76. <!-- Indicators -->
  77. <ol class="carousel-indicators">
  78. <?php for($i = 0; $i < count($slider_groups); $i++):
  79. $active = $i == 0 ? 'active' : '';
  80. ?>
  81. <li data-target="#octa-image-slider" data-slide-to="<?php echo $i;?>" class="<?php echo $active;?>"></li>
  82. <?php endfor; ?>
  83. </ol>
  84. <!-- Wrapper for slides -->
  85. <div class="carousel-inner" role="listbox">
  86. <?php
  87. $i = 0;
  88. if ( !empty($slider_groups) ): ?>
  89. <?php foreach ( $slider_groups as $slider ):
  90. $active = $i == 0 ? 'active' : ''; ?>
  91. <div class="item <?php echo $active;?>">
  92. <?php if($slider['slider_image']): ?>
  93. <img src="<?php echo wp_get_attachment_url($slider['slider_image']); ?>" alt="Carousel Slider">
  94. <?php endif; ?>
  95. <div class="carousel-caption">
  96. <?php if($slider['slider_title']): ?>
  97. <h1 class="<?php echo $title_transform; ?>"><?php echo $slider['slider_title'];?></h1>
  98. <?php endif; ?>
  99. <?php if($slider['slider_desc']): ?>
  100. <p class="slider-content"><?php echo $slider['slider_desc'];?></p>
  101. <?php endif; ?>
  102. <?php if($slider['slider_btn_text']): ?>
  103. <a class="btn btn-border" target="_blank"href="<?php echo $slider['slider_btn_link'];?>"><?php echo $slider['slider_btn_text'];?></a>
  104. <?php endif; ?>
  105. </div>
  106. </div>
  107. <?php $i++;
  108. endforeach;?>
  109. <?php endif; ?>
  110. </div>
  111. <!-- Controls -->
  112. <a class="left-control carousel-control" href="#octa-image-slider" role="button" data-slide="prev">
  113. <span class="icon-left ion-ios-arrow-thin-left" aria-hidden="true"></span>
  114. <span class="sr-only"><?php esc_html_e('Previous', 'octa');?></span>
  115. </a>
  116. <a class="right-control carousel-control" href="#octa-image-slider"role="button" data-slide="next">
  117. <span class="icon-right ion-ios-arrow-thin-right" aria-hidden="true"></span>
  118. <span class="sr-only"><?php esc_html_e('Next', 'octa');?></span>
  119. </a>
  120. </div>
  121. <?php endif; ?>
  122. <div class="container">
  123. <div class="row category-item padding">
  124. <?php
  125. $sticky = array(
  126. 'posts_per_page' =>3 ,
  127. 'category_name' => 'fashion',
  128. 'post__in' => get_option( 'sticky_posts' ),
  129. 'ignore_sticky_posts' => 1
  130. );
  131. $sticky = new WP_Query( $sticky );
  132. while($sticky->have_posts()) : $sticky->the_post();
  133. ?>
  134. <div class="col-md-4">
  135. <div class="post-img">
  136. <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a>
  137. <div class="border-separate"></div>
  138. <div class="entry-meta">
  139. <?php the_category(); ?>
  140. </div>
  141. </div>
  142. </div>
  143. <?php endwhile; wp_reset_query(); ?>
  144. </div>
  145. </div>
  146. <?php endif; ?>
  147. <div id="primary" class="content-area">
  148. <main id="main" class="site-main" role="main">
  149. <div class="container">
  150. <div class="row">
  151. <?php if($widget_position=='left') :?>
  152. <!-- start left sidebar -->
  153. <div class="col-md-4 col-sm-12 col-xs-12">
  154. <?php get_sidebar(); ?>
  155. </div>
  156. <!-- end left sidebar -->
  157. <?php endif; ?>
  158. <?php if($widget_position=='no_sidebar') :?>
  159. <div class="col-md-12">
  160. <?php else: ?>
  161. <div class="col-md-8">
  162. <?php endif; ?>
  163. <div class="row">
  164. <div class="single-full-width">
  165. <div class="col-md-12 col-sm-12 col-xs-12">
  166. <?php
  167. $query = new Wp_Query($query_args);
  168. while($query->have_posts()) : $query->the_post();?>
  169. <header class="entry-header text-center">
  170. <?php if(has_category()):?>
  171. <!-- Post category -->
  172. <span><?php the_category(); ?></span>
  173. <?php endif;?>
  174. <?php
  175. the_title( '<h2 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h2>' );
  176. if ( 'post' === get_post_type() ) : ?>
  177. <div class="entry-meta">
  178. <?php if(get_the_date()):?>
  179. <!-- Post date time -->
  180. <span><a href="<?php the_permalink();?>"><?php the_date(); ?></a></span>
  181. <?php endif;?>
  182. <span>
  183. <a href="<?php the_permalink();?>">
  184. <?php comments_number( '- no responses', '- 1 Comments', '% responses' ); ?>
  185. </a>
  186. </span>
  187. </div><!-- .entry-meta -->
  188. <?php endif; ?>
  189. </header><!-- .entry-header -->
  190. <div class="post-thumbnails">
  191. <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a>
  192. </div>
  193. <div class="entry-content">
  194. <p class="text-center"><?php echo wp_trim_words( get_the_content(),30, ''); ?></p>
  195. </div>
  196. <footer class="entry-footer">
  197. <div class="content-btn text-center">
  198. <a href="<?php the_permalink(); ?>" class="btn btn-border"><?php esc_html_e('Continue Reading', 'octa');?></a>
  199. </div>
  200. <div class="author-deatils">
  201. <div class="author text-left">
  202. <a href="<?php the_permalink();?>">
  203. <i>
  204. <?php esc_html_e('By :', 'octa'); ?>
  205. <?php the_author(); ?>
  206. </i>
  207. </a>
  208. </div>
  209. <div class="social-share text-right">
  210. <?php echo octa_social_share(); ?>
  211. </div>
  212. </div>
  213. </footer><!-- .entry-footer -->
  214. <?php endwhile; wp_reset_query(); ?>
  215. </div>
  216. </div>
  217. </div>
  218. <div class="row">
  219. <div class="grid">
  220. <?php if(have_posts()): ?>
  221. <?php if ( is_home() && ! is_front_page() ) : ?>
  222. <header>
  223. <h1 class="page-title screen-reader-text">
  224. <?php single_post_title(); ?>
  225. </h1>
  226. </header>
  227. <?php endif; ?>
  228. <?php
  229. while ( have_posts() ) : the_post();
  230. ?>
  231. <div class="col-md-6 col-sm-12 col-xs-12 grid-item">
  232. <?php
  233. get_template_part( 'template-parts/content', get_post_format() );
  234. ?>
  235. </div>
  236. <?php
  237. endwhile;
  238. //the_posts_navigation();
  239. ?>
  240. <?php else : ?>
  241. <?php get_template_part( 'template-parts/content', 'none' ); ?>
  242. <?php endif; ?>
  243. </div>
  244. </div>
  245. <?php octa_pagination(); ?>
  246. </div>
  247. <?php if($widget_position=='right') :?>
  248. <!-- start right sidebar -->
  249. <div class="col-md-4 col-sm-12 col-xs-12">
  250. <?php get_sidebar(); ?>
  251. </div>
  252. <!-- end right sidebar -->
  253. <?php endif; ?>
  254. </div>
  255. </div>
  256. </main><!-- #main -->
  257. </div><!-- #primary -->
  258. <?php
  259. get_footer();