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'); ...


8

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 ) { ...


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 ...


4

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) { ...


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

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

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

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

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

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

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

I think the best way to do this is using the loop, in the loop you need to get the terms for all associated posts. <?php if (have_posts()) : <while (have_posts()) : the_post(); //thecode endwhile; endif; ?>


2

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).


2

Well first of all you can use the menu feature in the newer WordPress. First you want to activate the fact that you want to use this feature via your functions.php file. // This theme uses wp_nav_menu() in two locations. register_nav_menus( array( 'primary' => __( 'Primary Navigation', 'your_theme_name' ), 'secondary' => __('Secondary ...


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 ...


2

Same as Matthews, tried it and works like a charm, I think you might have a plugin conflict. Alternatively, check if data is written to DB, but I really don't think that's the case, because the pages work fine


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

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 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 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

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

Ok I found a solution thanks to this: Using wp_dropdown_categories in widget options Here is the code I used instead: function form( $instance ) { /* Default Widget Settings */ $defaults = array( 'title' => 'Highlight Category' ); $instance = wp_parse_args( (array) $instance, $defaults ); ?> <!-- Widget Title --> ...


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 = ...



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