<?php
/**
 * The template for displaying search results pages
 *
 * @link https://developer.wordpress.org/themes/basics/template-hierarchy/#search-result
 *
 * @package Oficina_de_Suport_theme
 */

get_header();
?>

	<main id="primary" class="site-main">

		<?php if ( have_posts() ) : ?>

			<header class="page-header">
			</header><!-- .page-header -->

<?php 
// check if is ofisuport-ajut
if ( get_post_type( get_the_ID() ) == 'ofisuport-ajut'){ ?>
    <section id="filteredfunds" class="ofisuport-filtered-funds ofisuport-ajuts-filtrats">
      <aside id="fundsfilter" class="ofisuport-filter-funds ofisuport-fitre-ajuts">

        <script type="text/javascript">
          <!-- https://stackoverflow.com/a/48314274 -->
          (function($) {
          $('.fund-filter').ready(function() {
            $('.oficinasuport-titol-opcions').click(function() {
              $(this).siblings(".filter").toggle();
            });
          });
          })(jQuery);
        </script>
				<?php ofisuport_ajuts_filters_form(); // function defined in the plugin ?>

      </aside>
<?php } elseif ( in_category ( 'faq' ) ) { ?>
		<section id="filteredsearch" class="ofisuport-searched-query ofisuport-search-faqs">
   
       <?php //if( in_category('faq') ) : ?>
         <?php ofisuport_display_faqs_labels(); ?>
         <?php ofisuport_display_faqs_search(); ?>
       <?php //endif; //end if is_category faq ?>
   

<?php } else { ?>
		<section id="filteredsearch" class="ofisuport-searched-query">
      <?php
      /* translators: %s: search query. */
      printf( esc_html__( 'Search Results for: %s', 'ofisuport' ), '<br/><span class="h5 search-query">' . get_search_query() . '</span>' );
?>
<?php }; // end if is ofisuport-ajut ?>
    <content class="archive-posts <?php ofisuport_class_posttype(); ?>">

			<?php
			/* Start the Loop */
			while ( have_posts() ) :
				the_post();

				/**
				 * Run the loop for the search to output the results.
				 * If you want to overload this in a child theme then include a file
				 * called content-search.php and that will be used instead.
				 */
				get_template_part( 'template-parts/content', 'search' );

			endwhile;

			the_posts_navigation();

		else :

			get_template_part( 'template-parts/content', 'none' );

		endif;
		?>

		</content>
   </section>
	</main><!-- #main -->

<?php
get_sidebar();
get_footer();
