Trying to inject twitter metadata into using wp_head action in functions.php – get_the_excerpt() returns null
Trying to inject twitter metadata into using wp_head action in functions.php – get_the_excerpt() returns null
Trying to inject twitter metadata into using wp_head action in functions.php – get_the_excerpt() returns null
I am really not sure what’s causing this. Can you try with a minimal content in header.php? Something like this and see if the problem occurs? <!doctype html> <html <?php language_attributes(); ?>> <head> <meta charset=”<?php bloginfo( ‘charset’ ); ?>”> <meta name=”viewport” content=”width=device-width, initial-scale=1″> <?php wp_head(); ?> </head> <body <?php body_class(); ?>> And, meta tags doesn’t … Read more
If CSS is not outputting inside wp_head, it may imply that they’re not being enqueued correctly. See here for more info. Maybe they’re hardcoded in the theme file? In header.php? As for scripts, my guess is that they are being enqueued and set to trigger during footer actions, so the fact that you’re not calling … Read more
Nope, that won’t work. By the time WordPress starts evaluating the shortcode in your content, the head of the site has already been assembled, so you can no longer add an action to it. Looking at the execution order of hooks gives you a clue how to do this. First, you must avoid echoing scripts. … Read more
That code must run before the wp_head hook fires or nothing will happen, and when tested in a mu-plugin file it does work. I suspect that you are trying to hook that function too late– perhaps from inside a theme template file after get_header (in most cases). Place that code in the theme’s functions.php or … Read more
I found the best solution was to add a custom field, head, and then build a short plugin to add the contents to the head tag: add_action(‘wp_head’, ‘add_HTML_head’); function add_HTML_head(){ global $post; if(!empty($post)){ // get custom field for ‘head’ $headHTML = get_post_meta($post->ID, ‘head’, true); if(!empty($headHTML)){ echo $headHTML; } } } I’ve packaged it up into … Read more
IMHO, I still think that loading scripts and styles directly in the header is bad practice as it is always a problem removing them and loading them coditionally. The best way to work around this is to create a [child theme] and then copy header.php to your child theme. WordPress will load your child theme’s … Read more
You can try this (untested): add_action( ‘wp_head’, function(){ // your conditions: if( is_home() || is_category() ) { // access the global SyntaxHighlighter object instantiated at ‘init’. global $SyntaxHighlighter; // remove your action hooks: remove_action( ‘wp_head’, array( $SyntaxHighlighter, ‘output_header_placeholder’ ), 15 ); remove_action( ‘wp_footer’, array( $SyntaxHighlighter, ‘maybe_output_scripts’ ), 15 ); } } ); to remove these … Read more
Hook into wp_head in your functions.php file. add_action(‘wp_head’, ‘add_your_stuff’); function add_your_stuff() { ?> <link rel=”shortcut icon” href=”https://wordpress.stackexchange.com/questions/157869/<?php echo get_stylesheet_directory_uri();?>/favicon.ico” type=”image/x-icon” /> <link rel=”apple-touch-icon” href=”<?php echo get_stylesheet_directory_uri();?>/apple-touch-icon.png” /> <link rel=”apple-touch-icon” sizes=”57×57″ href=”<?php echo get_stylesheet_directory_uri();?>/apple-touch-icon-57×57.png” /> <link rel=”apple-touch-icon” sizes=”72×72″ href=”<?php echo get_stylesheet_directory_uri();?>/apple-touch-icon-72×72.png” /> <link rel=”apple-touch-icon” sizes=”76×76″ href=”<?php echo get_stylesheet_directory_uri();?>/apple-touch-icon-76×76.png” /> <link rel=”apple-touch-icon” sizes=”114×114″ href=”<?php echo get_stylesheet_directory_uri();?>/apple-touch-icon-114×114.png” /> … Read more
WP Core actually uses Open Sans font; it’s not a plugin. there is a plugin that removes it, but you can probably simply dequeue or deregister it. adding this to functions.php should work; if you want it removed from the backend as well, hook into the admin_print_styles action. function dequeue_opensans_css() { wp_dequeue_style( ‘open-sans’ ); } … Read more