Articles of select

How to number the options in a wp_dropdown_pages() select?

I’m using wp_dropdown_pages() but would like to number the options returned for the user. So instead of something like… <option value=’http://someurl’>item one</option> <option value=’http://someurl’>item two</option> <option value=’http://someurl’>item three</option> I end up with: <option value=’http://someurl’>1. page one</option> <option value=’http://someurl’>2. page two</option> <option value=’http://someurl’>3. page three</option> How would one go about doing that with the output of […]

Select box saves but doesn't update value in admin

I have a select dropdown in my custom meta box in the admin area. It offers two options Approved and In Progress. When I select an option and save it the database is updated, but the value in the admin area is not. What I see is the first item from the list displayed in […]

Woocommerce: Changing the variations select default value?

At my site i want to change the default value of the selecter that appears, when different variations exists. If anyone can give me a clue of how and where this is done, it would be highly appreciated!

How to Query Database for posts with certain Taxonomy Term

I want to write a select query to return data on only posts which have are associated with the taxonomy term food-and-beverage SELECT wp_postmeta . * , wp_posts.post_name FROM wp_posts, wp_postmeta, wp_terms, wp_term_relationships WHERE wp_posts.post_type = ‘projects’ AND wp_posts.post_status = ‘publish’ AND wp_posts.ID = wp_postmeta.post_id AND wp_term_relationships.object_id = wp_posts.ID AND wp_term_relationships.term_taxonomy_id = wp_terms.term_id AND wp_terms.slug […]

How to deal with multiple select options using register_setting() theme options

I’m using Ian Stewart’s Sample Theme Options for a lightweight Theme Options panel. INSERTION FAILED I need to insert Multiple categories into db, where I used the following code: <select multiple=”multiple” name=”site_options[categorychoice]”> <?php $args = array( ‘orderby’ => ‘name’, ‘parent’ => 0, ‘exclude’ => 1 ); $categories = get_categories( $args ); foreach ($categories as $category) […]

Admin menu bar dropdown opens when I click on a form <select> element (Chrome)

Whenever I click on a <select> element within a form, it opens not only the relevant dropdown but at the same time the first dropdown menu of the admin menu bar. It seems to be an issue with Google Chrome, as this doesn’t happen with Firefox. Does anyone else have the same issue ? Any […]

Exclude Duplicate Posts in this SELECT Query

I have this custom select query that pulls a specified number of posts from a specific category and displays them in the order of the latest comments. The problem is that if a post has both of the latest comments, it will get shown twice. I would like it to somehow detect duplicate posts and […]

Filtering custom posts with Ajax

I looked in other questions, searched on Google… And got nothing. I need to filter the posts from a custom post type based on the selected value. I have another part of the site where I use Ajax and everything works fine. I tried to follow the same logic, but everytime I change the select […]

How do I properly format the user_role array?

I used a role editor recently and needed to delete a role. After deleting it I noticed that it began to appear as blank in the edit user role drop-down. After a bit of investigating and deleting entries from the database. I renabled more_fields and the blank boxes reappeared. I then did a db search […]

How to dynamically save a selected option from page “Templates” selectbox?

When I select a template for a page from the “Templates” selectbox, the selected item gets “value=selected” only after I hit save draft/publish/update. <option value=’template-gallery.php’ selected=’selected’>Gallery</option> How can the option receive the value “selected” without the need of save/publish/update hit button? (like on widgets page: they get saved without page refresh) Thank you!