Display posts if a custom field value is equal to another custom field value

There’s some contradiction between your question and the code you provided, so I’m not exactly sure which of two scenarios you’re dealing with. Scenario 1 – You want to show all Shops with a specific value for shop-id and all Restaurants with the same specific value for restaurant-id. Let’s say that value is 20. You … Read more

Upload files programmatically to users

it was just missing $upload_dir[‘path’] . “https://wordpress.stackexchange.com/” . $upload_file_name in $uploaded_file[‘attach_id’] = wp_insert_attachment($attachment, $upload_dir[‘path’] . “https://wordpress.stackexchange.com/” . $upload_file_name); require_once(ABSPATH . ‘wp-admin/includes/image.php’); //Generate the metadata for the attachment, and update the database record. $attach_data = wp_generate_attachment_metadata($uploaded_file[‘attach_id’], $upload_dir[‘path’] . “https://wordpress.stackexchange.com/” . $upload_file_name);

how to set default value for checkbox in wordpress

I think the problem might could be the logic with using checked… <input type=”checkbox” name=”aps_display_post_title” value=”yes” <?php if ($aps_display_post_title != ‘no’) {echo ‘checked’;} ?> /> …on the other hand then running sanitize_text_field on the checkbox value might also be causing the problem. Instead you might want to break the logic down differently so it is … Read more

Checked() showing up twice in custom fields

checked() will echo the result by default. That’s the problem. To concat, you need to disable echo functionality by specify third param to false: echo ‘<input type=”checkbox” id=”my_meta_box_check1″ name=”my_meta_box_check1″ ‘ . checked( $check, “on”, false ) . ‘/>’;

Datepicker not supporting timepicker

WordPress supports only datepicker. If you want to add timepicker in datepicker you have to use jquery-ui-timepicker-addon as extension in your theme or plug-in. Add css and js as below add_action(‘wp_enqueue_scripts’, ‘custom_datepicker’); function custom_datepicker() { //wp_enqueue_script(‘jquery-ui-datepicker’); //wp_enqueue_script(‘jquery-ui-core’); wp_enqueue_script(‘jquery-ui-timepicker-addon’,get_stylesheet_directory_uri().’/js/jquery-ui-timepicker-addon.js’,array()); wp_enqueue_style(‘jquery-ui-timepicker-addon’,get_stylesheet_directory_uri().’/css/jquery-ui-timepicker-addon.css’,array()); wp_enqueue_style(‘jquery-ui’,get_stylesheet_directory_uri().’/css/jquery-ui.css’,array()); } You can download all css and js files from this link http://trentrichardson.com/examples/timepicker/ Call timepicker … Read more

Custom options page checkbox will not save, despite working with text

Don’t comment out your validation code remember you are using it to validate the data, so its returning nothing right now, so its saving nothing, try this: add_action(‘admin_bar_menu’, ‘make_parent_node’, 999); function make_parent_node($wp_admin_bar) { $args = array( ‘id’ => ‘test1234’, // id of the existing child node (New > Post) ‘title’ => ‘test’, // alter the … Read more

Check if the value of a field has changed on save_post

Usually there is no way to check if the meta data is updated or not, but you can use updated_postmeta and added_post_meta to get kinda similar functionality. Please have a look at the below code- add_action( ‘updated_postmeta’, ‘the_dramatist_updated_postmeta’, 10, 4 ); add_action( ‘added_post_meta’, ‘the_dramatist_updated_postmeta’, 10, 4 ); function the_dramatist_updated_postmeta( $meta_id, $object_id, $meta_key, $meta_value ) { … Read more