storing wp_head in a variable?
This function doesn’t take any params, so there is no nice way of doing it. But of course you can do this PHP way using output buffering 😉 ob_start(); wp_head(); $var = ob_get_clean();
This function doesn’t take any params, so there is no nice way of doing it. But of course you can do this PHP way using output buffering 😉 ob_start(); wp_head(); $var = ob_get_clean();
If we look at the file /wp-includes/default-filters.php we can find these two lines in there add_action( ‘wp_head’, ‘feed_links’, 2 ); add_action( ‘wp_head’, ‘feed_links_extra’, 3 ); so if we want to remove these actions, we can do it with these two lines in functions.php: remove_action(‘wp_head’,’feed_links’,2); remove_action(‘wp_head’,’feed_links_extra’,3); So the feed links will be removed from the <head> … Read more
First of all, you’re trying to deregister a stylesheet that doesn’t exist. Here is how the genericon stylesheet is enqueued in twenty fourteen wp_enqueue_style( ‘genericons’, get_template_directory_uri() . ‘/genericons/genericons.css’, array(), ‘3.0.2’ ); You are trying to dequeue the stylesheet file name. Here is the wp_enqueue_style() function wp_enqueue_style( $handle, $src, $deps, $ver, $media ); The important part … Read more
If you want to use different meta tags for different pages I recommend you to use custom field values. If you prefer to do it with conditional functions, try this: add_action( ‘wp_head’,’carlos_head_meta_page’ ); function carlos_head_meta_page() { if ( is_page(‘4’) ) { $description = ‘tag1’; } else { $description = ‘tag2’; } ?> <meta name=”description” content=”<?php … Read more
If you look at the source code, you can see that wp_enqueue_style( ‘crayon’ ) is called in Crayon::enqueue_resources() which itself is called either from either Crayon::the_content() or Crayon::wp_head(). The code in Crayon::wp_head is: if (!CrayonGlobalSettings::val(CrayonSettings::EFFICIENT_ENQUEUE) || CrayonGlobalSettings::val(CrayonSettings::TAG_EDITOR_FRONT)) { CrayonLog::debug(‘head: force enqueue’); // Efficient enqueuing disabled, always load despite enqueuing or not in the_post self::enqueue_resources(); } … Read more
Thank you for your help! This solution works with my theme: function remove_all_theme_styles() { if ( is_page_template(‘template-landing.php’) ) { global $wp_styles; $wp_styles->queue = array(); } } add_action(‘wp_print_styles’, ‘remove_all_theme_styles’, 100);
Well thank you for this question i did this after you posted this function category_title( $title ){ if( is_category(‘name1’) ){ $title=”name1 title”; }elseif( is_category(‘name2’) ){ $title=”name2 title”; } return $title; } add_filter( ‘get_the_archive_title’, ‘category_title’ ); Hope this helps
Pull the add_action() outside of the function, and put the conditional inside the callback. Also, if you’re printing a script directly, use wp_print_scripts instead of wp_head. You also have a syntax error. function testingone(){ if( get_option( ‘MyOptionName’ ) ) { ?> <script>var Script = GoesHere; </script> <?php } } add_action( ‘wp_print_scripts’,’testingone’ );
wp_head function causes 30px blank space [closed]
Trying to inject twitter metadata into using wp_head action in functions.php – get_the_excerpt() returns null