How can I apply this function to a single page ID:

function exclude_jobs_locations($args){
    $exclude = "40";
    $args["exclude"] = $exclude;
    return $args;

Can I also exclude child categories when parent category is excluded?

I've tried with:

function exclude_jobs_locations_uk($args){  
if( is_page( 2094 ) ) {
    $exclude = "40";
    $args["exclude"] = $exclude;
return $args;

But something goes wrong.

I use this function to exclude category from:

// Creating list on non-empty job location                    
$jobloc_select = wp_dropdown_categories(apply_filters('sjb_job_location_filter_args', array(
                    'show_option_none' => __('Location', 'simple-job-board'),
                    'hide_empty'       => 0,
                    'name'             => 'selected_location',
                    'orderby'          => 'NAME',
                    'order'            => 'ASC',
                    'class'            => 'sjb-form-control',
                    'hierarchical'     => TRUE,
                    'value_field'      => 'slug',
                    'taxonomy'         => 'jobpost_location',                        
                    'selected'         => $selected_location,
                    'echo'             => FALSE,
  • What is sjb_job_location_filter_args? That appears to be specific to some plugin. Note that 3rd-party plugin support is off-topic here.
    – Milo
    Apr 3, 2016 at 15:35
  • yes, i must hook that function Apr 3, 2016 at 17:08
  • we don't know what it is or when it runs, how can we answer your question?
    – Milo
    Apr 3, 2016 at 17:39

2 Answers 2


Assuming your function runs generally, to limit it to a specific page use

if( is_page( 2094 ) ) {

The location of the function definition doesn't matter.

P.S. Regarding excluding categories . . . yeah, we'd need to know a lot more about what's going on with the called (plugin?) function

  • no, not working like that. Apr 4, 2016 at 10:56
  • 1
    We need a lot more information to help. Before limiting your function to a specific page ,does it work? What does it do? Where's that code, default $args, etc. Help me help you.
    – dg4220
    Apr 4, 2016 at 16:24

The solution was to make a template:

if (!is_page_template('jobs-uk.php'))
add_filter('sjb_job_location_filter_args', 'exclude_jobs_locations_uk');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.