[wp-hackers] Issue with Custom Post Type Archive and custom search form
Becky Resler
becky.absolute at gmail.com
Fri Apr 20 21:52:39 UTC 2012
I'm creating a plugin that sets up a job board for a client's website. I
set up a custom post type for the job openings and a custom taxonomy for
job opening categories.
When I set up the custom post type, I set it to have have an archive
page. The code for my CPT is below.
$labels = array(
'name' => _x('Job Openings', 'post
type general name'),
'singular_name' => _x('Job Opening', 'post
type singular name'),
'add_new' => _x('Add New',
'job_opening'),
'add_new_item' => __('Add New Job Opening'),
'edit_item' => __('Edit Job Opening'),
'new_item' => __('New Job Opening'),
'view_item' => __('View Job Opening'),
'search_items' => __('Search Job Openings'),
'not_found' => __('No job openings found'),
'not_found_in_trash' => __('No job openings
found in Trash'),
'parent_item_colon' => __('Parent Job Opening:'),
'menu_name' => __('Job Openings')
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_nav_menus' => true,
'query_var' => true,
'capability_type' => 'post',
'hierarchical' => false,
'menu_position' => 20,
'supports' => array('title', 'editor',
'author'),
'has_archive' => 'job-board',
'can_export' => true,
'rewrite' => array('slug' =>
'job-board/%post_id%', 'with_front' => false)
);
I have a custom template for the archive for my custom post type. On
that template, I have added a search form to filter down the results by
keyword, category (custom taxonomy), author, and a couple custom meta
values. The form is posting to the archive page.
I'm hooking into the *request* filter to add my filters to the query ...
add_filter('request', array(&$this, 'modify_job_board_archive_query'));
Things are working just fine except for when I filter by category or
author. When I filter by category, the category archive template is used
rather than the custom post type archive template. Same thing with the
author ... author archive template is used.
I can't figure out where to hook into to make sure that my custom post
type archive template is used.
Any ideas? Or won't I be able to hook into the core WordPress
functionality for this?
Thanks in advance.
Becky
More information about the wp-hackers
mailing list