No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 
 
 
 

124 líneas
3.4 KiB

  1. <?php
  2. /**
  3. * Template Name: FAQ
  4. *
  5. * Page template with normal content area including an FAQ section after the post.
  6. *
  7. */
  8. get_header() ?>
  9. <?php the_post() ?>
  10. <section id="content" class="articles">
  11. <header id="post-<?php the_ID(); ?>" <?php post_class('section-header'); ?>>
  12. <h1 class="title"><?php the_title() ?></h1>
  13. <div class="intro content">
  14. <?php the_content() ?>
  15. </div>
  16. </header>
  17. <?php
  18. /*
  19. * @Sidebar Content before
  20. */
  21. get_sidebar('content-before'); ?>
  22. <div class="inner">
  23. <?php
  24. /**
  25. * FAQ entries
  26. * grouped by topic
  27. * ordered by menu_order *
  28. */
  29. $faq_ids = get_posts(array(
  30. 'post_type' => 'faq',
  31. 'posts_per_page' => -1,
  32. 'fields' => 'ids',
  33. 'meta_query' => array(
  34. 'relation' => 'OR',
  35. array(
  36. 'key' => '_hide',
  37. 'value' => 1,
  38. 'compare' => 'NOT LIKE',
  39. ),
  40. array(
  41. 'key' => '_hide',
  42. 'value' => 'bug #23268',
  43. 'compare' => 'NOT EXISTS',
  44. )
  45. ),
  46. ));
  47. $topic_term_names = get_terms(array(
  48. 'taxonomy' => 'topic',
  49. 'object_ids' => $faq_ids,
  50. 'fields' => 'names',
  51. 'orderby' => 'order', // needs plugin https://github.com/stuttter/wp-term-order/
  52. 'order' => 'ASC',
  53. ));
  54. ?>
  55. <?php if ( !empty($topic_term_names) && !is_wp_error($topic_term_names) ) { ?>
  56. <?php foreach ( $topic_term_names as $topic_term_name ) { ?>
  57. <?php
  58. $faq_options = array(
  59. 'post_type' => 'faq',
  60. 'tax_query' => array(
  61. array(
  62. 'field' => 'name',
  63. 'taxonomy' => 'topic',
  64. 'terms' => $topic_term_name,
  65. )
  66. ),
  67. 'meta_query' => array(
  68. 'relation' => 'OR',
  69. array(
  70. 'key' => '_hide',
  71. 'value' => 1,
  72. 'compare' => 'NOT LIKE',
  73. ),
  74. array(
  75. 'key' => '_hide',
  76. 'value' => 'bug #23268',
  77. 'compare' => 'NOT EXISTS',
  78. )
  79. ),
  80. 'posts_per_page' => -1,
  81. 'orderby' => 'menu_order',
  82. 'order' => 'ASC',
  83. );
  84. $faq_query = new WP_Query($faq_options);
  85. ?>
  86. <?php if ( $faq_query->have_posts() ) { ?>
  87. <?php while ( $faq_query->have_posts() ) {
  88. $faq_query->the_post(); ?>
  89. <?php
  90. $post_id = get_the_ID();
  91. $post_type = get_post_type($post_id);
  92. $post_slug = sandbox_get_the_slug();
  93. $content = apply_filters('the_content', get_the_content());
  94. ?>
  95. <article id="<?php echo $post_slug; ?>" <?php post_class() ?>>
  96. <h2 class="title accordeon"><a href="#content-<?php echo $post_slug; ?>"><?php the_title() ?></a></h2>
  97. <?php if ( !empty($content) ) { ?>
  98. <div id="content-<?php echo $post_slug; ?>" class="inner content">
  99. <?php echo $content; ?>
  100. </div>
  101. <?php } ?>
  102. </article><!-- .post -->
  103. <?php } ?>
  104. <?php wp_reset_postdata(); ?>
  105. <?php } ?>
  106. <?php } ?>
  107. <?php } ?>
  108. </div>
  109. <?php
  110. /*
  111. * @Sidebar Content after
  112. */
  113. get_sidebar('content-after'); ?>
  114. </section>
  115. <?php get_footer() ?>