Filter results with custom field values and dropdown

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> <option value=”10″>10</option> <option value=”20″>20</option> </select> </form> <?php /* Reset filter */ ?> <p><a href=”https://wordpress.stackexchange.com/questions/83928/<?php the_permalink(); ?>”>Clear filter</a></p> <?php if( !isset($_POST[‘my_size’]) || … Read more

How to store the value of a custom field dropdown select for post referencing?

selected() was big help for setting a default value. The rest I found in this brilliant meta box tutorial: http://code.tutsplus.com/tutorials/how-to-create-custom-wordpress-writemeta-boxes–wp-20336 with examples for text input, checkboxes and dropdown. Also Custom post type’s slug gets wrong when adding a custom meta box explained me how to correctly handle the current post object so it doesn’t get … Read more

Does wordpress have something like content-type?

Yes there are lot of ways you can achieve this by using plugin or pragmatically This Plugin will create custom content types as well as custom fields for specific content type: https://wordpress.org/plugins/wck-custom-fields-and-custom-post-types-creator/ However you can also do this via pragmatically: http://code.tutsplus.com/tutorials/a-guide-to-wordpress-custom-post-types-creation-display-and-meta-boxes–wp-27645 You can also check these functions from WordPress Codex which can be helpfull for … Read more

Fetch and show multiple custom fields via AJAX

To pass data from js back to PHP simplest way is use json_encode or, in WP, its wrappers wp_send_json, wp_send_json_error and wp_send_json_success. Usage example: On PHP side function get_latest_product_meta() { $post_id = (int) filter_input(INPUT_GET, ‘post_id’, FILTER_SANITIZE_NUMBER_INT); $post_id or wp_send_json_error(); // array_shift because when used like so `get_post_meta` return array of arrays… $data = array_map(‘array_shift’, get_post_meta($post_id)); … Read more

Add custom option to Standard Page Attributes Meta Box

Unfortunately not. The only way is to deregister the metabox, and then re-register it, supplying your own callback function which mimics the original metabox, but with your alterations (making sure the names of the inputs do not change). This method is outlined in these posts: custom post type taxonomies UI radiobuttons not checkboxes Custom-Taxonomy as … Read more

Saving Custom Field in Attachment Window in WordPress 3.5

I wanted to be able to add author information to my attachments and merged this code: http://www.billerickson.net/wordpress-add-custom-fields-media-gallery/ with the one you refer to. I Got it to work fully in the modal window via AJAX. The modified code is as follows: /** * Add Author Name and URL fields to media uploader * * @param … Read more

Date, Time, and Timezones

What is the purpose of the timezone setting in the Admin -> Settings section? Since WordPress handles time zone on its own (separately from native PHP functionality) that is where the setting made and result is stored in options. Whenever anything that works with timezones needs to happen, the time zone setting is retrieved and … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)