Unwanted blank lines before tag

the_content doesn’t affect the DOCTYPE and <html> tags, only the post/page content. One of your plugins, or something else in the theme is either throwing an error, or is printing something earlier than it should. Have you tried: Disabling each plugin one by one and see when it is fixed. Editing wp-config.php and adding define( … Read more

Change date number to another language/script?

Please try this way: Change date, the_date, the_time to get_date, get_the_date, get_the_time. function KhmerNumDate ($text) { $text = str_replace(‘1’, ‘១’, $text); $text = str_replace(‘2’, ‘២’, $text); $text = str_replace(‘3’, ‘៣’, $text); $text = str_replace(‘4’, ‘៤’, $text); $text = str_replace(‘5’, ‘៥’, $text); $text = str_replace(‘6’, ‘៦’, $text); $text = str_replace(‘7’, ‘៧’, $text); $text = str_replace(‘8’, ‘៨’, … Read more

Enqueued Stylesheets Effecting Admin Styles

You could do it like this: function theme_styles(){ /* * This if() statement is unnecessary, as wp_enqueue_scripts * doesn’t fire on the admin pages. * if( is_admin() ) { * return; * } */ wp_enqueue_style( ‘theme-styles’, get_template_directory_uri() . ‘/css/all.css’, array(), false, ‘all’ ); } add_action( ‘wp_enqueue_scripts’, ‘theme_styles’ ); References is_admin() Also, note that the wp_enqueue_scripts … Read more

Disable the Custom Internal CSS added by theme.json for Certain Pages

We can look into the wp_enqueue_global_styles() function, that calls wp_should_load_separate_core_block_assets() and see it contains e.g. the should_load_separate_core_block_assets filter but we can’t disable the global styles on the front-end, using this filter because of: /* * Global styles should be printed in the head when loading all styles combined. * The footer should only be used … Read more

Adding WordPress colorpicker in widget settings

The following worked for me. I using class attribute instead of ID to match multiple color pickers. <script type=”text/javascript”> jQuery(document).ready(function($) { jQuery(‘.color-picker’).on(‘focus’, function(){ var parent = jQuery(this).parent(); jQuery(this).wpColorPicker() parent.find(‘.wp-color-result’).click(); }); }); </script> My Widget form is set up like : <p> <label for=”<?php echo $this->get_field_id( ‘font_color’ ); ?>” style=”display:block;”><?php _e( ‘Font Color:’ ); ?></label> <input … Read more

How to allow admins to create a sidebar from the admin

Create a function that register sidebars, using register_sidebar, starting from an option: add_action(‘widgets_init’, ‘my_custom_sidebars’); function my_custom_sidebars() { $sidebars = get_option(‘my_theme_sidebars’); // get all the sidebars names if ( ! empty($sidebars) ) { // add a sidebar for every sidebar name foreach ( $sidebars as $sidebar ) { if ( empty($sidebar) ) continue; register_sidebar(array( ‘name’ => … Read more