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

My child theme doesn’t work Error: “The parent theme is missing. Please install your parent theme”

There are three things to check: Is your parent theme complete and what is the exact spelling of the parent theme’s name in its style.css. Uppercase and lowercase are important. Is the child theme directory named parentname-child. It should be in the themes directory, not in a subdirectory of the parent theme. Does the child … Read more

Are content.php and content-single.php the same?

No, content.php and content-single.php are not the same thing. In your example CODE: if (get_post_format() == false) { get_template_part(‘content’, ‘single’); } else { get_template_part(‘content’, get_post_format()); } WordPress will load content-single.php when get_post_format() is false. However, get_template_part( $slug, $name ) may still try to load content.php when you call it with get_template_part(‘content’, get_post_format()); in the following … Read more

How do I add settings to the Background Options Page?

The page content for custom backgrounds is created in wp-admin/custom-background.php. There is no action available where the fields are printed. To add new fields we have to print JavaScript into the page footer. The action is ‘admin_footer-appearance_page_custom-background’. To save those field values we have to hook into ‘load-appearance_page_custom-background’. The following example adds a new option … Read more

Should `get_template_directory_uri()` be escaped?

In that function we find a hook: return apply_filters( ‘template_directory_uri’, $template_dir_uri, $template, $theme_root_uri ); So, yes, the URI can be changed by plugins, and you should escape its returned value. The same principle applies to all WordPress URI functions, like get_home_url(), get_site_url() and so on. Keep in mind that there are not only good plugin … Read more

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