save_post not working with attachments

Not really, attachments are still not “full post types”. Manny Flerumond hints this quite well in this thread: Was thinking about this the past few days: currently any media files uploaded to a WordPress site defaults to the post status of inherit, which is a holdover to when media attachments were just that. Media was … Read more

Add_meta_box not appearing, but does appear in screen options

You missed one argument in the $args for add_meta_box. The correct use would be (Codex): add_meta_box( $id, $title, $callback, $post_type, $context, $priority, $callback_args ); You forgot to set the context, add it and you should be fine. add_meta_box( ‘content-on-page’, ‘Content On Page’, ‘ila_render_meta_box’, ‘page’, ‘normal’, // add this line ‘high’ );

Select box saves but doesn’t update value in admin

The second parameter of selected() has to agree with the value attribute of the current <option>. So assuming you have stuffed $selected with the value given by the relevant get_post_meta(), the following should work for you: <label for=”myplugin_meta_box_select”>Status:</label> <select name=”myplugin_meta_box_select” id=”myplugin_meta_box_select”> <option value=”Approved” <?php selected( $selected, ‘Approved’ ); ?>>Approved</option> <option value=”In Progress” <?php selected( $selected, … Read more

How to remove “publish metabox” from each post type

If you’re familiar with Browser Developer Tools you can quickly find the metabox ID ( which is the container div id ). In this case it’s called submitdiv. We can remove it by using the remove_meta_box() function which has a format like this: remove_meta_box( ‘metabox_id’, ‘post_type’, ‘default_position’ ); remove_meta_box( ‘submitdiv’, ‘post’, ‘side’ ); Here’s a … Read more

How to search by metadata using REST API

How can I search it by metadata? As far as I know, there’s no standard/built-in way of doing that (for the time being). But with custom coding, you can make it possible: You can append a city to the query string: /wp-json/wp/v2/horario_busao?city=London And then use the rest_{$this->post_type}_query filter to set the meta key/value pair which … Read more

wp_editor() usage in custom meta box

This may not solve the problem, but I hope it helps you. In the sky_post_excerpts() function, I used this to display the TinyMCE/classic editor: (the $data is get_post_meta($post->ID, ‘skyscraper_post’, true)) <?php wp_editor( $data, ‘post_meta_box’, array(‘textarea_name’=>’skyscraper_post’)); ?> In the post_meta_box_save() function, I saved the meta like so, where $allowed is wp_kses_allowed_html(): update_post_meta( $post_id, ‘skyscraper_post’, wp_kses( $_POST[‘skyscraper_post’], … Read more

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