WordPress Gutenberg – Sidebar get posts list based on selected category
WordPress Gutenberg – Sidebar get posts list based on selected category
WordPress Gutenberg – Sidebar get posts list based on selected category
How to set value selected using select2 jquery plugin
Editable select options in quick edit OR in plugin settings
How to Remove Active css from woocommerce variation?
Found it. There was an extra closing slash on the opening select field.
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’);
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, ‘taxonomy’ => ‘tshirt_categories’, ‘hide_if_empty’ => false ); ?> <h2>By Category</h2> <form action=”<?php bloginfo(‘url’); ?>” method=”get”> <div> <?php wp_dropdown_categories($args); ?> <input type=”submit” … Read more
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 $categories = get_categories(‘hide_empty=0’); // the … Read more
Use get_the_ID() instead of the_ID(). the_ID() will echo’ed the ID of posting: <option value=”<? the_ID(); ?>” <?php selected(get_the_ID(), $instance[‘post_to_display’]); ?>><?php the_title(); ?></option>
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 … Read more