How set featured posts using checkbox in post edit screen?

You can do this by following these steps: Add a custom meta box to your posts Create a function to save the meta data using the save_post action Add the ‘meta_key’ query argument to whatever query you are using. Place this in your themes functions.php file: function register_post_assets(){ add_meta_box(‘featured-post’, __(‘Featured Post’), ‘add_featured_meta_box’, ‘post’, ‘advanced’, ‘high’); … Read more

How to correctly call custom field dates into a posts_where filter using SQL statements

Thanks to AmbitiousAmoeba for the answer. The following improved code solves the problem: function filter_where( $where=”” ) { global $wpdb; $where .= ” AND (($wpdb->postmeta.meta_key = ‘original_date’ AND $wpdb->postmeta.meta_value >= ‘2000-01-01’) AND ($wpdb->postmeta.meta_key = ‘original_date’ AND $wpdb->postmeta.meta_value <= ‘2004-12-31’)) “; return where; } add_filter(‘posts_where’, ‘filter_where’); query_posts($query_string); while (have_posts()) : the_post(); the_content(); endwhile;

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