

/**
 * Filter Jobs Query
 */
function germany_jobs_filter_query($query) {
    if (!is_admin() && $query->is_main_query() && (is_post_type_archive('job') || is_post_type_archive('job_listing'))) {
        
        $meta_query = $query->get('meta_query');
        if ( ! is_array( $meta_query ) ) {
            $meta_query = array();
        }

        $tax_query = $query->get('tax_query');
        if ( ! is_array( $tax_query ) ) {
            $tax_query = array();
        }

        // Location Filter
        if (!empty($_GET['location'])) {
            $location = sanitize_text_field($_GET['location']);
            
            if (class_exists('WP_Job_Manager')) {
                // WP Job Manager uses _job_location meta
                $meta_query[] = array(
                    'key'     => '_job_location',
                    'value'   => $location,
                    'compare' => 'LIKE'
                );
            } else {
                // Custom theme uses location meta
                $meta_query[] = array(
                    'key'     => 'location',
                    'value'   => $location,
                    'compare' => 'LIKE'
                );
            }
        }

        // Job Type Filter
        if (!empty($_GET['type'])) {
            $type = sanitize_text_field($_GET['type']);
            
            if (class_exists('WP_Job_Manager')) {
                // WP Job Manager uses job_listing_type taxonomy
                $tax_query[] = array(
                    'taxonomy' => 'job_listing_type',
                    'field'    => 'name',
                    'terms'    => $type,
                );
            } else {
                // Custom theme uses type meta
                $meta_query[] = array(
                    'key'     => 'type',
                    'value'   => $type,
                    'compare' => '='
                );
            }
        }

        if (!empty($meta_query)) {
            $query->set('meta_query', $meta_query);
        }

        if (!empty($tax_query)) {
            $query->set('tax_query', $tax_query);
        }
    }
}
add_action('pre_get_posts', 'germany_jobs_filter_query');
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="https://www.mykbelgelendirme.com/sitemaps.xsl" ?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><sitemap>
							<loc>https://www.mykbelgelendirme.com/post-sitemap1.xml</loc>
							<lastmod>2025-12-03T22:50:58+00:00</lastmod>
						</sitemap><sitemap>
							<loc>https://www.mykbelgelendirme.com/page-sitemap1.xml</loc>
							<lastmod>2025-12-04T00:25:27+00:00</lastmod>
						</sitemap><sitemap>	
							<loc>https://www.mykbelgelendirme.com/category-sitemap1.xml</loc>
							<lastmod>2026-04-19T09:29:38+00:00</lastmod>
						</sitemap></sitemapindex>