• Hi!

    Im super new to web development but ive been trying to work on my site myself and im almost finished but for the life of me (and 3 days of trying) I can not get my site to exclude categories on these two drop downs

    Ive tried what seems to be the common fixes but no luck

    ?? Any help would be appreciated

    First drop down

    <?php if($xoouserultra->get_option( ‘uultra_front_publisher_allows_category’ )!=’no’){?>
    <div class=”field_row”>
    <p><?php echo __(‘Category:’,’xoousers’)?></p>

    <p>

    <?php

    $cats = get_the_category( $post->ID );
    $selected = 0;
    if ( $cats )
    {
    $selected = $cats[0]->term_id;
    }

    if ( $cat_type == ‘normal’ ) {
    wp_dropdown_categories( ‘show_option_none=’ . __( ‘– Select –‘, ‘xoousers’ ) . ‘&hierarchical=1&hide_empty=0&orderby=name&name=category[]&id=cat&show_count=0&title_li=&use_desc_for_title=1&class=xoouserultra-input requiredField&exclude=’ . $exclude . ‘&selected=’ . $selected );
    } else if ( $cat_type == ‘ajax’ ) {
    wp_dropdown_categories( ‘show_option_none=’ . __( ‘– Select –‘, ‘xoousers’ ) . ‘&hierarchical=1&hide_empty=0&orderby=name&name=category[]&id=cat-ajax&show_count=0&title_li=&use_desc_for_title=1&class=xoouserultra-input requiredField&depth=1&exclude=’ . $exclude . ‘&selected=’ . $selected );
    } else {
    wpuf_category_checklist( $curpost->ID, false, ‘category’, $exclude);
    }

    ?>
    </p>
    </div>

    <?php }?>

    Second Drop down:

    <?php

    $args = array(
    ‘hierarchical’ => ‘0’,
    ‘hide_empty’ => ‘0’

    );
    $categories = get_categories($args);
    foreach ($categories as $cat) {
    if ($cat->category_parent == 0) {
    $catID = $cat->cat_ID;
    ?>
    <option value=”<?php echo $cat->cat_name; ?>”><?php echo $cat->cat_name; ?></option>

    <?php
    $args2 = array(
    ‘hide_empty’ => ‘0’,
    ‘parent’ => $catID
    );
    $categories = get_categories($args2);
    foreach ($categories as $cat) { ?>
    <option value=”<?php echo $cat->slug; ?>”>- <?php echo $cat->cat_name; ?></option>
    <?php } ?>

    <?php } else { ?>
    <?php }
    } ?>

Viewing 1 replies (of 1 total)
  • Where are you getting the value of the $exclude variable? I don’t see it set here anywhere – is it correctly set somewhere else in the code to the category number(s) you want to exclude?

    What happens if you test it by substituting the category numbers you want directly, eg if you wanted to exclude category #5 you’d say:

    wp_dropdown_categories( 'show_option_none=' . __( '-- Select --', 'xoousers' ) . '&hierarchical=1&hide_empty=0&orderby=name&name=category[]&id=cat&show_count=0&title_li=&use_desc_for_title=1&class=xoouserultra-input requiredField&exclude=5&selected=' . $selected );

Viewing 1 replies (of 1 total)
  • The topic ‘Cant get exclude categories to work for drop down’ is closed to new replies.