Tag Info

Hot answers tagged

18

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


3

you can do that using JQuery autocomplete plugin and once you have included all of the needed JS files just add this code after your new post form $terms = get_terms("post_tag"); $tags = ''; $count = count($terms); if ( $count > 0 ){ foreach ( $terms as $term ) { $tags .= '"'.$term->name.'", '; } $tags = substr($tags,0,-2); } ...


3

You can use 'publish' === get_post_status( $id ), where $id could be the current page ID retrieved via get_the_ID() or any other.


3

It looks like this is supported by Contact Form 7 natively, it's just not very obvious on how to make it happen. Here's a documentation page explaining the functionality: http://contactform7.com/selectable-recipient-with-pipes/ Basically all you have to do is put the values like so: Visible Value|actual-form-value What comes before the pipe "|" character ...


2

If I understand your question correctly, then it's a matter of joining the code from two answers from the following Questions of this Stack: Changing Top Level Items into Radio Buttons in the Categories Meta Box? Make parent categories not selectable This is the result, top-level categories are converted to radio buttons, so only one can be selected. ...


2

I believe this is what you were looking for. I moved back to using a class because what you were using would very easily conflict with someone else's code who decided to use the function names select_box_add_meta_box(), select_box_content() and/or select_box_save_postdata(), which is reasonably likely. The class name WPSE_85107 is only likely to conflict ...


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

Look at the code for the tag box in wp-admin/includes/meta-boxes.php and the function tagBox in wp-admin/js/post.js. You may adapt or reuse these functions.


2

I'm assuming your $selected variable contains an array of values for the currently selected items? You can't use selected in this case (with multi select boxes) because it only compares two strings. It won't test to see if the value is in an array. Instead, use a ternary statement and in_array() <?php foreach ($cats as $cat_list ) { $selected = ...


2

Thanks to Ed Nailor & Kucrut ! http://ednailor.com/2011/01/24/adding-custom-css-classes-to-sidebar-widgets/ // __________________________________________________________ // // CUSTOM CLASS BY WIDGETS function kc_widget_form_extend( $instance, $widget ) { if ( !isset($instance['classes']) ) $instance['classes'] = null; /* Set your predetermied ...


2

You don't need to write these SQL queries. you can utilize WP_Query api. the following will display posts that has terms 'food-and-beverage' in tags. $query = new WP_Query( array( 'tag' => 'food-and-beverage' ) ); if you use different taxonomy, use that instead of tag. as you need to filter posts by using other options, you can check whole api ...


2

(I realize you're leaning away from this, but maybe if you can get it working, it's worthwhile. With the recent perfomance improvements in 3.4 for WP_Query, this could be worthwhile.) WP_Query is the right decision if this is a secondary loop. Otherwise, you might look into pre_get_posts. When you use WP_Query make sure that: You don't use a reserved ...


2

If I have understood correctly, you could use get_the_ID() and compare the value with get_queried_object_id() to archive this: $args = array( 'post_type'=> 'portfolio', 'posts_per_page' =>100, 'offset'=> 0 ); $myposts = get_posts( $args ); $current_id = get_queried_object_id(); foreach ( $myposts as $post ) { setup_postdata( $post ); ...


2

You don't have to rebuild the metabox... you can just add a pseudo term via the get_terms filter. This will add an "All Terms" term to your checkbox list, (assuming a hierarchical taxonomy). add_filter( 'get_terms', 'wpa104168_all_terms', 10, 3 ); function wpa104168_all_terms ( $terms, $taxonomies, $args ){ if ( is_admin() && ...


1

On the Product Edit page for the variable product, click on the "Variations" tab. Once you setup variations for the Colour you can set a "Default selection" at the bottom: http://cld.wthms.co/7LIv This will be the default option selected when a customer visits the page (if it is in stock). Example: http://cld.wthms.co/YQFO


1

(0. Retrieve the meta value with get_post_custom (in order to highlight the selected value in the select input).) Query posts with get_posts( array( 'post_type' => 'services', 'post_status' => 'publish' ) ) Loop through the results with foreach and build your select input. Hook into save_post (add_action('save_post', 'my_save_meta') to store the ...


1

You do not need to be messing with the database connection. WordPress provide a database object called $wpdb. It is not really clear what you are doing. Your title reads "help me select thumb", but your code is actually pulling a lot of different post statuses, not thumbnails. In fact, your code does not have anything to do with thumbnails at all, that I ...


1

You can use the following piece of code. <form action="<?php bloginfo('url'); ?>" method="get"> <?php $select = wp_dropdown_pages( array( 'post_type' => 'ce_artists', 'show_option_none' => 'Select Artist', 'echo' => 0 ...


1

The problem here is that you don’t allow PHP to read more than one value, because all values use the same name site_options[categorychoice], so they overwrite each other, and the last one wins. You need more brackets. Set the name attribute of your select element to site_options[categorychoice][], and all values will be read by PHP.


1

I would suggest, that you switch from "URl query argument" style to arrays. This is a "feature" that is more a left over on some functions that is only available for backwards compatibility reasons than anything else. Here's a reworked version of your current arguments: wp_dropdown_pages( array( 'title_li' => '', 'depth' => TRUE, ...


1

The trouble is to do with how quick edit works - WordPress uses a hidden <div /> to generate the form, which will have already had select2 applied (and thusly, the positions already calculated). Your click event listener on the body won't fire when you need it, since the core event handler for quick edit returns false, stopping any event propagation. ...


1

Ahh it turns out it wasn't able to stay selected because I was using the "strtolower" function to remove capital letters. Which in turn caused there to be a mismatch between the selected value and the saved value in the database. add_action( 'show_user_profile', 'product_selection_field', 3 ); add_action( 'edit_user_profile', 'product_selection_field', 3 ...


1

I would remove the jQuery save function that was added... and then... Try this for the form function: public function form( $instance ) { // Code for editing/adding title and adding IDs to the <select> object // ... <?php printf ( '<select multiple="multiple" name="%s[]" id="%s" class="widefat" size="15" ...


1

Add something like this to the functions file: function current_tag($tags) { global $wp_query; $cid = $wp_query->query_vars['cat']; foreach($tags as $tag) { // match tagid to $cid } } add_filter( 'get_the_tags', 'current_tag'); This won't work by itself, but it will be a good start for getting the right information to the ...


1

OMG - i falied to clean "$selected" value... hope this helps someone if you get confused for a moment like i did <?php $postId = $_POST['postid']; // the value is recieved properly $currentCategory = get_the_category($postId); // the value is recieved properly $currentCategoryId = $currentCategory[0]->term_id; // the value is assigned properly ...


1

Here is what I discovered and use, maybe it will help you: function custom_posttype_dropdown($name, $selected) { $out = ""; $posts = get_posts( array( 'post_type' => 'bctap_templates', 'numberposts' => -1 ) ); if($posts ) { $out = '<select name="'.$name.'" ...


1

Found it. There was an extra closing slash on the opening select field.


1

this isn't a WordPress thing, just an issue with your JS. this: jQuery("select[name^='post_author']").attr('selectedIndex',selected); should be: jQuery("select[name^='post_author']").val(selected).attr('selected','selected');


1

Remove DISTINCT And add GROUP BY $wpdb->posts.ID before 'ORDER BY'



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