• Resolved doncarswell

    (@doncarswell)


    HI, check out this page https://ratethailand.com/category/restaurant-reviews/

    I have a jump menu with the code

    <li id="categories"><h2><?php _e('Posts by Category'); ?></h2>
    	<?php wp_dropdown_categories('show_option_none=Select category'); ?>
    
    <script type="text/javascript"><!--
        var dropdown = document.getElementById("cat");
        function onCatChange() {
    		if ( dropdown.options[dropdown.selectedIndex].value > 0 ) {
    			location.href = "<?php echo get_option('home');
    ?>/?cat="+dropdown.options[dropdown.selectedIndex].value;
    		}
        }
        dropdown.onchange = onCatChange;
    --></script>
    </li>

    But I would like for it to only show the child for this category and not the other categories.
    Also this is restaurant reviews, I will also have SHopping and pubs which will use the same archive.php file. So how can I get it to show the child for the particular category?

Viewing 1 replies (of 1 total)
  • You could pass in the queried category ID to wp_dropdown_categories.

    <?php wp_dropdown_categories('show_option_none=Select category&child_of='.get_query_var('cat')); ?>

    Failing that, if the ID isn’t carrying into cat, maybe try..

    <?php
    $querired_cat = get_cat_ID( get_query_var( 'category_name' ) );
    wp_dropdown_categories( 'show_option_none=Select category&child_of=' . $querired_cat ); ?>

Viewing 1 replies (of 1 total)
  • The topic ‘Having archive.php page with different jump menu's for each category’ is closed to new replies.