Tag Info

Hot answers tagged

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


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


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

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

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


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

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

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


1

The default widgets do not offer any hooks for that. You have to replace the default widget and add your field to the new class. The other option would be using JavaScript to insert the field, and a filter for 'update_option_widget_' . $widget->id_base to save the value. I think the separate class is the cleaner approach.


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

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

Seeing as my comments seemed to answer the question: To get access to the URL params you want $wp_query->query_vars['myvar']: http://wordpress.org/support/topic/how-to-pass-value-in-wordpress-url, e.g.: <?php global $wp_query; $node_id = 0; $args = array( 'post_type' => 'jobs', 'category_name' => ...


1

This doesn't really seem to be a WP question, but: as far as PHP goes, the function you're looking for is checkdate(). That said, you really should also do something client-side (that is, JS) for the user.


1

See the myplug_admin_page function. And see the selected calls inside it. selected works in a way that check the value of the item with the current saved value. In your selected calls the current saved value should be $input['select_it'] but.. no $input variable it's defined in that function. In that function the current saved value is in the var ...


1

Rename your <select> to something other than page_id. The problem is that page_id is already taken (and handled) by WordPress (as query var). This should do, for example: <?php if (isset($_GET['editevent']) && true == $_GET['editevent']) echo 'Post ID: '.$_GET['my_page_id']; ?> <form method="GET" action="#"> <select ...


1

This line $type = isset( $instance['type'] ); will set $type to either true or false which never matches the string you check for later: foreach ($types as $option) { echo '<option value="' . $option . '" id="' . $option . '"', $type == $option ? ' selected="selected"' : '', '>', $option, '</option>'; } You need to remove that $type = ...


1

I'm not a programmer so there's probably a far more efficient/correct way of doing this. Put this in functions.php or a custom plugin: function get_terms_by_post_type( $taxonomies, $post_types ) { global $wpdb; $query = $wpdb->get_results( "SELECT t.*, COUNT(*) from $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = ...


1

The save_post action will call your function and send it the $post_id, not $data and $postarr. Your select_box_save_postdata function needs to accept $post_id as its only parameter: add_action( 'save_post', 'select_box_save_postdata' ); function select_box_save_postdata( $post_id ) { $selected_item = null; // your form data is in the $_POST array ...


1

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


1

There're several things to note: get_settings() is deprecated and get_option() should be used instead WordPress comes with a function named select() that takes three arguments: Saved value, looped value, echo You're better off saving your key, than the HTML capable "title" element in your options. It's much safer to save in the DB an easier to compare as ...


1

You're probably better off to use get_users which returns an array of <?php // get all users, regardless of roll. If you do need to restrict by // role you can use the `role` argument: get_users(array('role' => 'author')); $uses = get_users(array('orderby' => 'nicename')); foreach ($users as $user) { // do stuff with $user, will have all 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

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

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

try : a:5:{ ...



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