All of same taxonomy?

<?php 
$categories = get_terms('metki', 'orderby=name&hide_empty=0');
if($categories){
 echo '<select-->';

 // call each object in the array (in this case category)
 foreach ($categories as $cat){

 // print the list item where the value attribute equal to the ID column and $cat->name - title headings
 echo "<option value="<a href=" . get_term_link($cat) . ">">{$cat->name}</option>";
}
 echo ";
}
?>


trying to create a La filter with taxonomies, and that when you click on any option from the list, the user is transferred to the page with posts with that tag.
So far only released a list of taxonomies in the list.
Did not work - went to the link another.

<select onchange="document.location=this.options[this.selectedIndex].value"><option selected="selected">Filter</option><option value="<a href=http://dogreb/metki/bolshaya-sobaka/>">big dog</option><option value="<a href=http://dogreb/metki/rotveyle/>">Rotale</option></select>
July 2nd 19 at 17:04
1 answer
July 2nd 19 at 17:06
Solution
pretty weird to value the whole link push, well, to hell with him, so...
you have to frame the script for the onChange:

if($categories){
 echo '<select onchange="document.location=this.options[this.selectedIndex].value">';
UPD: actually, I shouldn't... apparently, before the era of jQuery that was standard practice :)htmlbook.ru/html/attr/onchange</select>
I'm open to suggestions (just learn the basics of web-Virgo).
Unfortunately, this example does not work, as you said it throws a 404 page because the url adds tried to replace {$cat->slug} vseravno not ... - Timmy.Lockman80 commented on July 2nd 19 at 17:09
I don't know what it is... in General, too does not work... - Timmy.Lockman80 commented on July 2nd 19 at 17:12
when "it throws the 404"? when you select from the selector? - kimberly43 commented on July 2nd 19 at 17:15
... if that means an event already work out, and it is necessary to watch that it falls in value, the problem is the contents... - kimberly43 commented on July 2nd 19 at 17:18
: I wrote there, it is somehow like that in the link threw... now I try again to write in General when you select items from the selector to shovel me to the page site_name/post_type_name/post_name/ - Timmy.Lockman80 commented on July 2nd 19 at 17:21
damn she... and then - "" - Timmy.Lockman80 commented on July 2nd 19 at 17:24
a%20href=http:/dogreb/metki/bolshaya-sobaka/ - Timmy.Lockman80 commented on July 2nd 19 at 17:27
in dugacka - Timmy.Lockman80 commented on July 2nd 19 at 17:30
and replace {$cat->name} is also not working very well - Timmy.Lockman80 commented on July 2nd 19 at 17:33
Ah damn, you are talking to yourself as if :)))

let's parts, if you want me to tag:
1. refresh the page, press Ctrl-U (or whatever your browser's page source to), copy all the code selector (with all options) and show what gets there.

2. when you select one of the items in the selector - what's going on? options: a) nothing b) going straight on some page (don't matter what).

then - after answering these questions. - kimberly43 commented on July 2nd 19 at 17:36
: 1)Filtrona dobacaracol
2)going straight to 404 - Timmy.Lockman80 commented on July 2nd 19 at 17:39
: updated my question down below the code will be requested - Timmy.Lockman80 commented on July 2nd 19 at 17:42
get_term_link($cat) - gives the full reference code
esc_url(get_term_link($cat)) - and so a clear link to without HTML - kimberly43 commented on July 2nd 19 at 17:45
well, that is, change the first to the second - kimberly43 commented on July 2nd 19 at 17:48
: still not working... the url at the end it adds a%20href=http:/dogreb/metki/bolshaya-sobaka/ and the 404 page comes - Timmy.Lockman80 commented on July 2nd 19 at 17:51
again show me how the HTML looks selekta - kimberly43 commented on July 2nd 19 at 17:54
Oh, no, esc_url about is I messed up... - kimberly43 commented on July 2nd 19 at 17:57
: also... just in case updated the question - Timmy.Lockman80 commented on July 2nd 19 at 18:00
echo ""; - kimberly43 commented on July 2nd 19 at 18:03
in so - kimberly43 commented on July 2nd 19 at 18:06
in General, get_term_link gives a normal link, I didn't even notice that you're forced for some reason trying it in HTML to wrap :))) - kimberly43 commented on July 2nd 19 at 18:09
: had the same thought to remove the tags, but I see that you do not talk about it, don't even try it... And as always, the answer always lay in plain sight)
Thank you for the solution, good day to you - Timmy.Lockman80 commented on July 2nd 19 at 18:12

Find more questions by tags Web DevelopmentPHPWordPress