How to add a checkbox element to attachments editor with example

Set the ‘input’ to ‘html’ and write out the html for the input: function filter_attachment_fields_to_edit( $form_fields, $post ) { $foo = (bool) get_post_meta($post->ID, ‘foo’, true); $form_fields[‘foo’] = array( ‘label’ => ‘Is Foo’, ‘input’ => ‘html’, ‘html’ => ‘<label for=”attachments-‘.$post->ID.’-foo”> ‘. ‘<input type=”checkbox” id=”attachments-‘.$post->ID.’-foo” name=”attachments[‘.$post->ID.’][foo]” value=”1″‘.($foo ? ‘ checked=”checked”‘ : ”).’ /> Yes</label> ‘, ‘value’ => … Read more

Using TinyMce with textareas in meta boxes on custom post types

Here’s a pastebin with your code included. Get the old value of the tinyMCE $meta_biography = get_post_meta( $post->ID, ‘meta_biography’, true ); Call the TinyMCE Editor wp_editor( $meta_biography, ‘biography’, array( ‘wpautop’ => true, ‘media_buttons’ => false, ‘textarea_name’ => ‘meta_biography’, ‘textarea_rows’ => 10, ‘teeny’ => true ) ); Save The Editor Value or if nothing is there … Read more

Adding a custom field to the site identity menu

You’ll have to add your own customizer controls to achieve that. So for example, if you want to add Company Name, you can use this code: function my_register_additional_customizer_settings( $wp_customize ) { $wp_customize->add_setting( ‘my_company_name’, array( ‘default’ => ”, ‘type’ => ‘option’, // you can also use ‘theme_mod’ ‘capability’ => ‘edit_theme_options’ ), ); $wp_customize->add_control( new WP_Customize_Control( $wp_customize, … Read more

How can I use order_by to order by two meta_keys without excluding posts that don’t have those keys initialized?

I had a similar issue but couldn’t solved with the snippets on this thread. I had to order a query by: all ‘featured’ posts first (is_it_a_featured_etf) and by a numeric field (etf_aum) in DESC order after the featured ones. My solution: ‘meta_query’ => [ ‘relation’ => ‘OR’, ‘etf_aum’ => array( ‘key’ => ‘etf_aum’, ‘type’ => … Read more

SQL Query to copy value of a meta_key into another meta_key

First take a db backup! Second, in your question you mention the same meta_key, so made the following assumption: The meta_key you want to keep is “ehp_citation” The meta_key you want to change is “ehp_citation_old” * so make the correction accordingly Then you can try something like: UPDATE `wp_postmeta` AS pm_to_change LEFT JOIN `wp_postmeta` AS … Read more

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