- This topic has 5 replies, 2 voices, and was last updated 6 years, 1 month ago by
Steve.
-
AuthorPosts
-
-
December 9, 2015 at 4:19 pm #5285
bicho44MemberHi: Im here again :D:
I found an almost working version of the problem, but i need just a little help with something.
This is my code right now
$buscadores = $settings['buscarxcategorias']; foreach ($buscadores as $id => $value) { //echo $value; /* Obtengo la data de cada categoría */ $categoria = get_taxonomy($value); if ($categoria) { // piklist::pre($categoria); $catname= strtolower($categoria->labels->name); //piklist::pre($categoria); /* * Para saber el Nombre en Singular * $categoria->labels->name * * El valor debe ser url/cat/slug */ $url = esc_url( home_url( '/')); piklist('field', array( 'type' => 'select' , 'scope' => 'taxonomy' , 'field' => $catname , 'label' => $categoria->labels->name.' de Productos' , 'columns' => '9' , 'choices' => array('' => 'Seleccione para buscar') + piklist( get_terms($value, array('hide_empty' => false)) , array( 'slug' , 'name' ) ) ,'attributes' => array( 'onchange' => "window.document.location.href=this.options[this.selectedIndex].value;" ) ) ); } }The code almost works because i need in this part
piklist( get_terms($value, array('hide_empty' => false)) , array( 'slug' , 'name' ) )I have to change the
slugfor a full URL something likemysite.com/[taxonomy]/[slug]because thats the URL i need 😀The variable
$catnameis the taxonomy, so i only need away to construct the urlAny ideas of how can i make it happend?
I really thank everybody for the help.
—
Regards from patagonia
Fede -
December 10, 2015 at 3:48 pm #5293
SteveKeymasterDoes your
get_terms()code work? -
December 10, 2015 at 5:45 pm #5295
bicho44MemberYeah, the
get_terms()works, and theslugis published, but i need a little more than theslugi need almost the full url in that placeHow can i mix thing in that array? Im trying to use piklist all the way, lol 😀
Again Thanks in advance.
-
December 14, 2015 at 12:38 pm #5325
SteveKeymasterYou should be able to piece together the url using standard WordPress/PHP functions. You even know the taxonomy: $value.
-
December 14, 2015 at 4:51 pm #5346
bicho44MemberHI Steve:
I was a little busy, but i figure out, after you ask me about the
get_terms()function.And this is the code I made, is not pretty but works, je.
$buscadores = $settings['buscarxcategorias']; foreach ($buscadores as $id => $value) { //echo $value; /* Obtengo la data de cada categoría */ $categoria = get_taxonomy($value); if ($categoria) { // piklist::pre($categoria); $catname= remove_accents ( strtolower($categoria->labels->name)); //piklist::pre($categoria); /* * Para saber el Nombre en Singular * $categoria->labels->name * * El valor debe ser url/cat/slug */ $url = esc_url( home_url( '/')); $terms = get_terms($value, array('hide_empty' => false)); /** * Here I piece together the url to send the dropdown. * Not pretty but works. */ $menu=array(); foreach ($terms as $i => $v){ $menu[$url.$catname.'/'.$v->slug] = $v->name; } /* end URL glueing :D */ // Here the piklist part piklist('field', array( 'type' => 'select' , 'scope' => 'taxonomy' , 'field' => $catname , 'label' => $categoria->labels->name.' de Productos' , 'columns' => '9' , 'choices' => array('' => 'Seleccione para buscar') + $menu // Array with the links ,'attributes' => array( 'onchange' => "window.document.location.href=this.options[this.selectedIndex].value;" ) ) ); } }If anyone have a better way, please tell me, but for now its working, Yipieee!!!
-
December 14, 2015 at 5:11 pm #5347
SteveKeymasterI’ve used this in the past and it works pretty well:
return is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
-
-
AuthorPosts
- You must be logged in to reply to this topic.