feat(05-01): create archive query helper for Elementor integration

Add DDHH_JM_Archive class to modify job archive queries. Ensures
Elementor Loop Grid displays only published jobs sorted by date
(newest first) with no pagination limit.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-14 20:30:00 +09:00
parent 061a41033d
commit 75c2969c88
3 changed files with 52 additions and 0 deletions

View File

@@ -0,0 +1,48 @@
<?php
/**
* Archive class
*
* Handles job archive query modifications for Elementor template integration
*
* @package DDHH_Job_Manager
*/
// Exit if accessed directly.
defined( 'ABSPATH' ) || exit;
/**
* Archive class
*/
class DDHH_JM_Archive {
/**
* Initialize hooks
*/
public static function setup_hooks() {
// Modify archive query for published jobs
add_action( 'pre_get_posts', array( __CLASS__, 'modify_archive_query' ), 10 );
}
/**
* Modify job archive query to show only published jobs
*
* @param WP_Query $query The WordPress Query object.
*/
public static function modify_archive_query( $query ) {
// Only modify job_offer archive queries on the frontend
if ( is_admin() || ! $query->is_main_query() ) {
return;
}
// Check if this is a job_offer archive
if ( ! $query->is_post_type_archive( 'job_offer' ) ) {
return;
}
// Set query parameters for published jobs
$query->set( 'post_status', 'publish' );
$query->set( 'orderby', 'date' );
$query->set( 'order', 'DESC' );
$query->set( 'posts_per_page', -1 );
}
}

View File

@@ -65,6 +65,9 @@ class DDHH_JM_Job_Manager {
// Initialize notifications
add_action( 'init', array( 'DDHH_JM_Notifications', 'setup_hooks' ) );
// Initialize archive query helper
add_action( 'init', array( 'DDHH_JM_Archive', 'setup_hooks' ) );
// Initialize admin UI enhancements (admin-only)
if ( is_admin() ) {
add_action( 'init', array( 'DDHH_JM_Admin_UI', 'setup_hooks' ) );