Make WordPress Core

Opened 10 years ago

Closed 8 years ago

#28492 closed defect (bug) (invalid)

Categories Widget Dropdown Issue

Reported by: selinawdesign's profile selinawdesign Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.9.1
Component: Widgets Keywords:
Focuses: Cc:

Description

This is a follow-up to #15257.

Page in Question: http://selinawdesign.com/wp/live-french/news/

The drop-down version of the categories widget does not seem to work, but the list-view version does. I cleared the cache, hard refreshed, etc. and still no luck. I viewed the page source and the list-view has "a href" for each list-item whereas the drop-down version does not. I see that there is a script for the dropdown to populate an "a href" but it just doesn't seem to be working.

Whenever I select, say "Education," from the dropdown none of the posts that are categorized "Education" populate the new page. However when I do so from the list-view, the page changes accordingly.

Source for the dropdown:

<div class="wpb_wrapper">

			<div class="vc_wp_categories wpb_content_element"><div class="widget widget_categories"><h2 class="widgettitle">Categories</h2><select name='cat' id='cat' class='postform' >

	<option value='-1'>Select Category</option>

	<option class="level-0" value="48">Education</option>

	<option class="level-0" value="19">Events</option>

	<option class="level-0" value="14">News</option>

	<option class="level-1" value="59">&nbsp;&nbsp;&nbsp;Member Benefits</option>

	<option class="level-0" value="47">Youth</option>

</select>

 

<script type='text/javascript'>

/* <![CDATA[ */

	var dropdown = document.getElementById("cat");

	function onCatChange() {

		if ( dropdown.options[dropdown.selectedIndex].value > 0 ) {

			location.href = "http://selinawdesign.com/wp/?cat="+dropdown.options[dropdown.selectedIndex].value;

		}

	}

	dropdown.onchange = onCatChange;

/* ]]&gt; */

</script>

</div></div>

Source for list view:

<div class="wpb_wrapper">

			<div class="vc_wp_categories wpb_content_element"><div class="widget widget_categories"><h2 class="widgettitle">Categories</h2>		<ul>

	<li class="cat-item cat-item-48"><a href="http://selinawdesign.com/wp/category/education/" title="View all posts filed under Education">Education</a>

</li>

	<li class="cat-item cat-item-19"><a href="http://selinawdesign.com/wp/category/events/" title="View all posts filed under Events">Events</a>

</li>

	<li class="cat-item cat-item-14"><a href="http://selinawdesign.com/wp/category/news/" title="View all posts filed under News">News</a>

<ul class='children'>

	<li class="cat-item cat-item-59"><a href="http://selinawdesign.com/wp/category/news/memberbenefits/" title="View all posts filed under Member Benefits">Member Benefits</a>

</li>

</ul>

</li>

	<li class="cat-item cat-item-47"><a href="http://selinawdesign.com/wp/category/youth-3/" title="View all posts filed under Youth">Youth</a>

</li>

		</ul>

</div></div>

Change History (3)

#1 @westonruter
10 years ago

Thanks for the report, selinawdesign.

I notice when I click Member Benefits from the list, I am taken to a pretty URL: http://selinawdesign.com/wp/category/news/memberbenefits/

However, when I select Member Benefits from the dropdown, I am taken to a URL with a cat query parameter: http://selinawdesign.com/wp/?cat=59

WordPress is supposed to be automatically redirecting such /?cat=59 URLs to their “pretty” equivalents, like /category/news/memberbenefits/. I just tried this on my blog and it is working as expected. So it seems you have another plugin that is interfering with the cat query var so that WordPress is not recognizing it for selecting a category. What plugins do you have installed?

That being said, it would be better of the select dropdown would just include the final category link to begin with, instead of using a URL with a query var and redirecting. In other words, each option of the select should output get_category_link( $category_id ) instead of just the $category_id, and then this can be navigated to directly. This would also side-step the problem reported on selinawdesign.com as well.

#2 @westonruter
10 years ago

  • Keywords reporter-feedback added

#3 @afercia
8 years ago

  • Keywords reporter-feedback removed
  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

No feedback in 18 months. Also, seems it was not possible to reproduce the issue. Closing out. Please feel free to re-open with more information.

Note: See TracTickets for help on using tickets.