Using auth_redirect returns cannot modify header information

It works fine on my localhost as well. The reason it probably doesn’t work on your server is that it’s not using output buffering. Hooking into wp_head means that the page has already started printing to the client’s screen. Meaning auth_redirect‘s use of wp_redirect will fail: the headers have already been sent and you see … Read more

Change dns-prefetch to preconnect for external enqueued resources

There’s a filter, wp_resource_hints, but it only filters each “relation type” (i.e. preconnect, dns-prefetch, etc.) individually, rather than the whole $hints array in your question. However, you could use the filter to empty the array for dns-prefetch and add wp_resource_hints_scripts_styles() to the preconnect array, like this: add_filter( ‘wp_resource_hints’, function( $urls, $relation_type ) { if ( … Read more

append stylesheet via shortcode

here is a handy function i use a lot which is based on the_posts hook function check_for_shortcode($posts) { if ( empty($posts) ) return $posts; $flag = false; foreach ($posts as $post) { if ( stripos($post->post_content, ‘[YOUR_SHORTCODE_HERE’) ) $flag = true; break; } if ($flag){ //add scripts and styles here eg: //wp_enqueue_script //wp_enqueue_style } return $posts; … Read more

How to properly insert a stylesheet in wp_head

You can do it like this, put it in your functions.php : This is the correct way of doing it “the WordPress way”. <?php // Check if function exisits if (!function_exists(‘rg_templateScriptSetup’)) { // if not, create one function rg_templateScriptSetup() { // Register styles in WordPress wp_register_style(‘prefix-basic-css’, get_template_directory_uri(). ‘/css/basic-style.css’); // Register styles in WordPress wp_register_style(‘first-css’, get_template_directory_uri(). … Read more

use add_action(‘wp_head’) in a widget for generating dynamic CSS styles

Once the widgets are being evaluated, the head of your site is completed, so you cannot use wp_head anymore. Adding <style> tags is an option, but will indeed generate a warning from the validator. Using the customizer is possibly confusing, because it is supposed to be about theme looks in general, not about specific widgets. … Read more

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