Advertisement
FabianoMoier

Drop com categorias para pagina de busca

Feb 12th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. <!--E importante criar uma categoria pai para buscar as
  2. categorias desejadas nessa parte do codigo add o ID da categoria pai'child_of' => 56
  3. -->
  4.  
  5.  
  6. <form role="search" method="get" id="searchform" class="searchform" action="<?php echo esc_url( home_url( '/' ) ); ?>">
  7. <div> <span>LOJA</span><br />
  8. <input type="text" value="<?php echo get_search_query(); ?>" name="s" id="s" />
  9. <br />
  10. <span >CATEGORIA</span> <br />
  11. <select>
  12. <option value="-1">Selecione a categoria</option>
  13. <?php
  14. $categories = get_categories( array( 'child_of' => 56 ));
  15. foreach ( $categories as $category ) {
  16. printf( '<option value="%1$s">%2$s (%3$s)</option>',
  17. esc_attr( '' . $category->term_id ),
  18. esc_html( $category->cat_name ),
  19. esc_html( $category->category_count )
  20. );
  21. }
  22. ?>
  23.  
  24. </select>
  25. <br />
  26. <input type="submit" id="searchsubmit" value="<?php echo esc_attr_x( 'Search', 'submit button' ); ?>" />
  27. </div>
  28. </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement