Tag Info

Hot answers tagged

30

The parameter 'items_wrap' for wp_nav_menu() defaults to '<ul id="%1$s" class="%2$s">%3$s</ul>'. It is parsed with sprintf(): $nav_menu .= sprintf( $args->items_wrap , esc_attr( $wrap_id ) // %1$s , esc_attr( $wrap_class ) // %2$s , $items // %3$s ); The numbered placeholders – %1$s, %2$s, %3$s – refer to the ...


16

You can't do this with wp_nav_menu, because it outputs list items, and you'll generate invalid markup with your code. Try using wp_get_nav_menu_items() instead. A quick solution for a drop down menu with a custom walker: class Walker_Nav_Menu_Dropdown extends Walker_Nav_Menu{ // don't output children opening tag (`<ul>`) public function ...


9

Here is an example. I have also created a Gist with more generic code. add_action('add_meta_boxes', 'my_custom_metabox'); function my_custom_metabox() { add_meta_box('custom-taxonomy-dropdown','Brands','taxonomy_dropdowns_box','post','side','high'); } function taxonomy_dropdowns_box( $post ) { wp_nonce_field('custom-dropdown', 'dropdown-nonce'); ...


6

I downloaded this plugin and took a look and it does work as advertised for me. The function it uses for displaying the page list is: wp_list_pages(array( 'sort_column'=>'menu_order', 'depth'=>'4', 'title_li'=>'', 'exclude'=>$exclude )); ?> Which is very straightforward and does very explicitly order ...


4

You'll need to use get_posts and roll your own drop down. Something like this (somewhere in functions.php): <?php function wpse34320_type_dropdown( $post_type ) { $posts = get_posts( array( 'post_type' => $post_type, 'numberposts' => -1 ) ); if( ! $posts ) return; $out = '<select ...


4

Sorry about that feels a bit weird answering ones own question, but here you go.... Firstly declare the variable: (customcategory) global $userdata; $errors = array(); $title = trim($_POST['wpuf_post_title']); $customcategory = trim($_POST['customcategory']); $content = trim($_POST['wpuf_post_content']); $tags = ...


4

This suppose you have a custom post type "sponsors" and a custom taxonomy "types"... function custom_meta_box() { remove_meta_box( 'tagsdiv-types', 'sponsors', 'side' ); add_meta_box( 'tagsdiv-types', 'Types', 'types_meta_box', 'sponsors', 'side' ); } add_action('add_meta_boxes', 'custom_meta_box'); /* Prints the taxonomy box content */ function ...


3

Here is a quick snippet I use to get started on my projects: The first step is to add some code to the functions.php file. This is what will enable the WordPress Custom Navigation. The controls will be in Appearance>Menu's once your finished. Code for functions.php: <?php add_action( 'init', 'register_my_menus' ); function register_my_menus() { ...


3

This is what I do: Static Options <select id="<?php echo $this->get_field_id('posttype'); ?>" name="<?php echo $this->get_field_name('posttype'); ?>" class="widefat" style="width:100%;"> <option <?php selected( $instance['posttype'], 'Option 1'); ?> value="Option 1">Option 1</option> <option <?php ...


3

There are couple of things wrong with your code... when filtering it is not term that gives the ID of the term, but business (in this case), since this is the name you've provided for the drop-down menu. Replace all instances of term with business Taxonomy is not set when filtering. Remove this check from parse_query function. The following worked for ...


3

A filter called wp_dropdown_pages exists in the wp_dropdown_pages() function. That filter allows you to modify the output of the function. However, for the thing you want to do I would not recommend using this filter since this will apply to all code that calls wp_dropdown_pages(), including plugins. So, one way to approach your situation may be to simply ...


3

Yes, we can sort Wordpress posts in different orders, You can do following sorts without installing plugins. sort post by date ( ascending / descending ) Sort post by title (ascending / descending ) Sort post by comment count ( ascending / descending ) -- These are just basic we can do even more using categories and tags etc Wordpress already stores the ...


3

You can use the standard WordPress function, get the dropdown already formatted and solve both problems at once. Like so: define( 'WP_USE_THEMES', false ); require( './wp-load.php' ); wp_dropdown_categories( array( 'child_of' => 0, 'class' => 'postform', 'depth' => 0, 'echo' => 1, 'exclude' => ...


3

Actually, with a little digging this is quite easy to do. WooCommerce has already set up a filter so all you have to do it add a small snippet in your functions.php file. // Modify the default WooCommerce orderby dropdown // // Options: menu_order, popularity, rating, date, price, price-desc function my_woocommerce_catalog_orderby( $orderby ) { ...


3

You will need to write a custom walker extending Walker_Nav_Menu, more or less like so: class My_Custom_Nav_Walker extends Walker_Nav_Menu { function start_lvl(&$output, $depth = 0, $args = array()) { $output .= "\n<ul class=\"dropdown-menu\">\n"; } function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0) { ...


2

Take a look at the WooCommerce docs here: Tutorial – Customising checkout fields using actions and filters your code would look something like this: function my_custom_checkout_field( $checkout ) { woocommerce_form_field( 'my_field_name', array( 'type' => 'select', 'class' => array('my-field-class form-row-wide'), ...


2

Update your form to include the term-id, instead of just <input type="checkbox" /> use <input type="checkbox" name="taxonomy_id[]" value="'. $industryterm->term_id .'" />. That way you are actually sending along some values, in this case the term id. And in the args for wp_insert_post() make sure to include something like this: 'tax_input' ...


2

The dot . in your code is evaluated as string litral, and not concatenation. Meaning if $inpCnt was equal to 5 for example, php will search for name='scrape['.5.'][sponsors]' id= and will fail to find it. You can either remove the dots while still using the double quotes: $sponsors = str_replace( "name='scrape['$inpCnt'][sponsors]' id=", ...


2

Edited according to first comments and Pastebin code: <?php /* You can also leave 'action' blank: action="" */ ?> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <select name="my_size" id="size" class="postform" onchange="submit();"> <option selected="selected">Choose a size</option> ...


2

It's called a 'Mega Menu', it allows a full HTML control over dropdown elements of a menu. There is a free option here - http://wordpress.org/extend/plugins/jquery-mega-menu/ - and CodeCanyon offers a lot premium and fancy mega menu plugins to be purchased.


2

Hello Everyone out there, who are facing difficulty to display the parent and child taxonomies in drop down, i found the solution for the above problem...... edit the code in the functions.php file, before the code was $categories= get_categories('child_of='.$_POST['main_catid'].'hide_empty=0'); now edit the code, like this... $categories= ...


2

You can use wp_dropdown_categories() to create your dropdown: wp_dropdown_categories(array('taxonomy'=> 'post_tag','hide_empty' => 0, 'name' => 'my_tags')); Update the reason you are getting the term ID is because wp_dropdown_categories sets the ID's as values so instead of just echo'ing it out you need to get the term, something like: $term = ...


2

if you are using it in a metabox then you really don't need this part: onchange='document.location.href=this.options[this.selectedIndex].value;' So change the select fields to: <select name="event-dropdown"> <option value=""><?php echo esc_attr(__('Select Event')); ?></option> <?php //get saved data ...


2

You just need to pull the Labels via get_post_type_object(); <?php $args=array( 'public' => true, '_builtin' => false ); $output = 'names'; $operator = 'and'; $post_types=get_post_types($args,$output,$operator); ?> <select id="" name=""> <?php foreach ($post_types as $post_type ) { $label_obj = ...


2

The solution was very simple! Just use Superfish.js as instructed on http://users.tpg.com.au/j_birch/plugins/superfish/#getting-started Be sure to include superfish, hoverIntent and jQuery in your wordpress. In your custom js script file, something like this works like a charm: $('ul#theidofyourmenu').superfish({ delay: 600, // This will fire ...


1

wp_dropdown_categories has a hierarchical and depth options available. $args = array( 'show_option_all' => 'All Tshirt Categories', 'orderby' => 'ID', 'order' => 'ASC', 'hide_empty' => 1, 'child_of' => 0, 'hierarchical' => 1, 'depth' => 1, ...


1

WordPress has Custom Navigation Menus built-in. Simply register a theme_location for each menu in functions.php, then go to Dashboard -> Appearance -> Menus to create the custom menu(s), and apply the custom menu(s) to the appropriate Theme Location(s). The rest is a matter of CSS (or jQuery, if you really want to go that route).


1

I was just doing exactly this recently. Not sure how advanced you are so you may know some of this stuff already. I found this video to be very good (+ it's second part) I think one of the original pieces of research done was this I think Twenty Eleven also uses the superfish jquery plugin As the other poster mentioned you can find the twenty eleven code ...


1

You should be able to send the desired taxonomies as an argument to the function. This is untested, but should work: $args = array( 'taxonomy' => array( 'galleries', 'places' ) ); echo wp_dropdown_categories($args); For your reference, the function wp_dropdown_categories is defined in "wp-includes/category-template.php" on line ...



Only top voted, non community-wiki answers of a minimum length are eligible