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

Add custom field to media attachment image attribute in post editor

I wonder if you want to modify the HTML of the inserted image, with the image_send_to_editor or get_image_tag filters? If that’s the case, then here’s one example: /** * Add the data-ext-link-title and data-ext-link-url attributes to inserted images. */ add_filter( ‘image_send_to_editor’, function( $html, $id, $caption, $title, $align, $url, $size, $alt ) { if( $id > … 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

Get_post() with meta_key when compare is a date

I think you have error in your query. Please try this: $posts = get_posts(array( ‘post_type’ => ‘events’, ‘posts_per_page’ => -1, ‘meta_query’ => array( ‘meta_key’ => ‘from_datetime’, ‘type’ => ‘DATETIME’, // You can also try changing it to TIME or DATE if it doesn’t work ‘meta_value’ => date( “F d, Y g:i a” ), ‘meta_compare’ => … 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

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