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

get_header();
?>

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

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

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

<?php 
// check if is xarxaprod-ajut
if ( get_post_type( get_the_ID() ) == 'xarxaprod-ajut'){ ?>
    <section id="filteredfunds" class="xarxaprod-filtered-content xarxaprod-filtered-funds xarxaprod-ajuts-filtrats">
      <aside id="fundsfilter" class="xarxaprod-filter-funds xarxaprod-fitre-ajuts">
        <?php include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); if ( is_plugin_active( 'xarxaprod-wp-plugin/xarxaprod-wp-plugin.php' ) ) { // if plugin active do?> 
          <?php xarxaprod_ajuts_filters_form(); // function defined in the plugin ?>
        <?php  } //end if is_plugin_active ?>
      </aside>
<?php } elseif ( in_category ( 'faq' ) ) { ?>
		<section id="filteredsearch" class="xarxaprod-searched-query xarxaprod-search-faqs">
      <aside id="xarxaprod-faqs-nav" class="xarxaprod-faqs-aside">      
         <?php xarxaprod_display_faqs_labels(); ?>
         <?php xarxaprod_display_faqs_search(); ?>
      </aside>              

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