Questions tagged [wp-head]

Uses do_action() Calls 'wp_head' hook.

Filter by
Sorted by
Tagged with
2
votes
2answers
48 views

Change dns-prefetch to preconnect with correct protocol

I have this function in my functions.php file: function dns_prefetch_to_preconnect( $urls, $relation_type ) { if ( 'dns-prefetch' === $relation_type ) { $urls = []; } if ( '...
2
votes
1answer
3k views

Change Page's <title> Tag Using functions.php File

In my child theme's functions.php file, I'm trying to change a page's title tag: function custom_title() { return "Page Title"; } add_filter( 'wp_head', 'custom_title', 9999 ); The code above is ...
2
votes
2answers
3k views

How to remove unnecessary elements in the HTML document head

Is there a plugin or something that can help me out with deleting unnecessary elements in my code? I am in charge of fixing a WordPress site and have been asked to remove the following elements that ...
2
votes
0answers
50 views

Trying to inject twitter metadata into <head> using wp_head action in functions.php - get_the_excerpt() returns null

So I followed the "Add Twitter Cards without plugins" this tutorial for how to add twitter metatags into the header using the wp_head method. I have pretty much taken the code as is, and put it in ...
2
votes
0answers
405 views

wp_head function causes 30px blank space [closed]

I want my outer-wrapper to be full screen, but if use wp_head(); function it causes nearly 30px blank space from the top. If I use #outer-wrapper: margin: -30px auto; this time there is 30px blank ...
2
votes
1answer
4k views

Change meta tags programatically

Is there a way to change the meta tags not in the head but in a template file through code? I would like to change the meta tags <meta property="og:title" content="title" /> <meta ...
1
vote
4answers
13k views

add action wp_head not working

I am trying to add some code to the head (namely a block of tracking script) via a plugin I am making. The plugin has an interface where the user enters some details which are then added to the ...
1
vote
2answers
225 views

Replace category titles

I want to display different titles in category archives than the category title. I have created a function with if statements for this purpose: function category_titles_change() { if (...
1
vote
2answers
601 views

Is possible dequeue/remove style from wp_footer() hook and add on wp_head() hook?

I need unregister this enqueue style of wp_footer() hook and add it to the top of site with hook wp_head(), this is possible? I'm optimizing my theme to validate in W3C, and one of the requirements ...
1
vote
1answer
2k views

wp_head hook by page ID [closed]

I need help with this /* meta description to head */ add_action( 'wp_head','carlos_head_meta_page' ); function carlos_head_meta_page() { ?> <meta name="description" content="vale here"...
1
vote
2answers
3k views

Remove Genericons Helper CSS from twentyfourteen theme

I'd like to remove the genericons-css styles loaded by default into twentyfourteen theme. <link rel='stylesheet' id='genericons-css' href='http://ffwdconsulting.com/wp/wp-content/themes/...
1
vote
3answers
5k views

Manipulating wp_head content

I'd like to know if it is possible for me to manipulate the output of wp_head()? Right now I'm using the Yoast SEO plugin to add some social tags into my posts (og:*). Now this site is an remake of ...
1
vote
2answers
9k views

How do I edit wp_head and/or functions.php to remove rss-feed which isnt used and dont validate?

When using w3.org's validation tool Unicorn I get the following error/warning: URI: http://energyshop.se/hem/feed/ This feed does not validate. After looking into my source its there crystal clear ...
1
vote
1answer
2k views

Using auth_redirect returns cannot modify header information

I'm hooking auth_redirect to wp_head, but it's returning cannot modify header information. Do I have to hook it to a different action? Something that loads before wp_head? I tried hooking it to ...
1
vote
1answer
211 views

storing wp_head in a variable?

how to store WP_head and footer functions in a variable? Is that possible? I wanted to be like this. $var = wp_head(); How can achieve it?
1
vote
2answers
2k views

action hook wp_head higher priority as all other plugins/hooks

I work a bit with the wordpress API and I want to try to include a <meta>-tag into my head area of my website. This is my code (works everything fine!): class dmd_noindex_options_page{ ...
1
vote
2answers
17k views

Move all the JS files to the bottom|footer, the right way

In order to speedup my site load and prevent scripts from render the page I'm trying to move all the possible scripts (meaning JS files) from head to footer. After read and do some research I made ...
1
vote
1answer
3k views

wp_head() - list hooked actions with priorities?

I'd like to add something to wp_head() but I'm aiming precise location (like after style.css but before rtl.css and before my other custom script). I'm wondering if it's possible to list everything ...
1
vote
1answer
7k views

Fatal error: Call to undefined function get_post() with ajax

I have an index.php page with about link, which will get about author content from created page (post) inside WordPress dashboard with name about. I'm using Magnific Popup plugin for poups. I have ...
1
vote
2answers
3k views

Add HTML to single post <head> tag

If I have developed a separate HTML page that I wish to include inside my Wordpress site what is the best way of including it? In this case it requires a javascript library or stylesheet that is not ...
1
vote
2answers
4k views

adding meta data using plugin to top of head

It seems if you use the wp_head hook as an action to put your custom metadata into the head tags of your page, it is dependent on where the theme you are using calls the wp_head. In my case, it is at ...
1
vote
1answer
437 views

Custom plugin - $post_id in wp_head

(english is not my language so I'm sorry if I don't explain really good) My custom plugin get an URL from custom metabox and add it into the header.php My problem is that I can't get $post_id in my ...
1
vote
1answer
874 views

Removing Visual Composer head meta (works alone but not with IF)

I'm trying to remove the head meta added by VC, namely "meta name="generator" content="Powered by Visual Composer - drag and drop page builder for WordPress". If I add: add_action('init', '...
1
vote
1answer
48 views

Get latest posts from WordPress site without header, menu and sidebar

I have no knowledge about WordPress. However, I want to fetch and display the latest posts of a WordPress site in an application window. One way to do so is to use the RSS feed. However, this ...
1
vote
1answer
499 views

Create mobile navigation header with settings integration

I'm a seasoned programmer but a completely inexperienced WordPress developer. I'm trying to figure out how to create a header that only shows for mobile devices, and how to modify properties of that ...
1
vote
1answer
2k views

Add javascript to wp_head with call to plugin options?

I am trying to write a plugin in wordpress and have been doing it in stages, I understand how to add javascript to the wp_head however adding multiple function calls to the plugins options is ...
1
vote
1answer
128 views

How do I test my localhost WordPress project with VirtualBoxVM?

I'm working on a WordPress project set up with MAMP on localhost. I try testing the site on internet explorer with VirtualBoxVM by browsing to my local ip. My problem is, wp_head() outputs absolute ...
1
vote
2answers
1k views

Passing a variable via wp_head and then calling it on the page

As my question suggests I'm having difficulty creating a variable in the header, via functions.php and wp_head, and then calling that variable further down the page. For example, in functions.php ...
1
vote
1answer
89 views

Remove WordPress scripts

I am working on a custom page template in my theme and I want to remove all other styles and scripts which are loaded, like default theme style, jQuery & other scripts. I want to remove all for ...
1
vote
1answer
687 views

Header has extra HTML block at top before my code

I've been trying to fix the issue where wp_head loads in the body tag in wordpress, and I've discovered that when I look at the page source, an extra HTML block appears before the code from my header....
1
vote
0answers
281 views

wp_head function not outputting

I've been trying to figure out what I could possibly be doing wrong with this plugin I just coded, from what I see, everything should be working correctly. However, it's not doing anything at all. No ...
1
vote
1answer
56 views

What is the safe way to print tracking code / pixel code before </head> tag or </body> tag

What is the safe way to print tracking code / pixel code before </head> tag or </body> tag from theme options. In header.php I printed the following code before the </head> tag if (...
1
vote
1answer
44 views

How can I add Javascript in the header of all post pages and only post pages

I am using add_action('wp_head', 'function_that_returns_js_string') in functions.php but it is adding the string in the header across the site. How can this be narrowed down to be only included in ...
1
vote
0answers
309 views

How to disable/enable specific plugins for a mobile theme?

I would like to use a mobile theme for my website but not load all the plugins being used for the desktop version. Is there a way to achieve this without having to remove wp_head() from the theme and ...
1
vote
0answers
1k views

Adding Shortcode Values to wp_head

I'm trying to create a shortcode with attributes which then places the values in meta tags for SEO purpose. I know there a some plugins for this use, but I want a simple and reusable/extendable meta ...
1
vote
2answers
529 views

How to load plugin before the wordpress jquery?

I'm fixing a wordpress plugin that uses a 1.0.0 version of jquery. The jquery version automatically included in wordpress is 1.11.0. In a test site, the plugin is dependent on the 1.0.0 jquery and ...
1
vote
2answers
2k views

Edit title-tag in wp_head with yoast seo

I want to manipulate the html-title tag, so <title> these not the content of the title-tag! I use child-themes and it's inevitable, because the template have to be easy to update. So I have to ...
1
vote
0answers
181 views

How to modify default controls in Wordpress theme customizer

I'm trying modify the default control in the wordpress theme customizer specifically the action for the close button. By default clicking it will make you go back to the themes page, but I want it to ...
1
vote
2answers
544 views

CSS from textarea in options page to frontend what to do

I have a textarea for small css enhancements on the plugins page i output them directly to the head. My Question is how to sanitize the CSS i have validation function registered for the options with ...
1
vote
1answer
609 views

Remove adjacent_posts_rel_link under 3.2?

I'm trying to remove the adjacent_posts_rel_link links under WP3.2, i.e. remove these from wp_head: <link rel='prev' title='blah blah' href='http://...' /> <link rel='next' title='blah blah' ...
1
vote
3answers
1k views

removing wordpress generated code from the head section?

Specifically, I'm talking about the following which gets added automatically: 1) <script type='text/javascript' src='http://mysite.com/wp-includes/js/l10n.js?ver=20101110'></script> 2) &...
1
vote
1answer
76 views

How to replace a function using a child theme?

I have the following function where I would like to replace the image nopic.jpg I have updated by deleting some redundant options. if ( ! function_exists( 'TaskerDev_get_first_post_image_fnc' ) )...
0
votes
4answers
4k views

ACF custom field in <head> [closed]

I've created an image field using Image URL via the ACF plugin. This field appears across my pages. This field enables admin to change the background image for a selected class. Here's the code I ...
0
votes
2answers
484 views

How to get a single hook from wp_head()?

I am working on a custom post type and I don't want it to get all the clutter from wp_head(). However, I do want to show a specific hook, for example the YoastSEO meta tags. How do I call a specific ...
0
votes
3answers
10k views

wp_head() remove redundant scripts?

quick question. I'm using jquery for my current project (the latest release). A few plugins I'm using are using jquery as well and they are inserted through wp_head(). Since I want my website to ber ...
0
votes
1answer
206 views

How to hook into <head></head> container

I want to add my own <meta /> tag inside the <head></head> container on every page or post within the loop(). Is that possible? What hook(s) should I use for that?
0
votes
1answer
823 views

Would there be anything stopping me from removing both wp_head and wp_footer?

Some plugins rely on either wp_head or wp_footer or both to introduce their own stylesheets and JavaScript. Those scripts take time to load and slow down my website. Therefore, I would like manually ...
0
votes
1answer
23 views

Is it possible to modify the header with a content shortcode?

I'm guessing this is not possible, as wp_head() is probably finished before the content execution, but here's a quick example of what I'm trying to do: add_shortcode( 'header_content', function () { ...
0
votes
2answers
46 views

How can I change the <head> tag contents of individual Wordpress posts?

How can I change the tag contents of individual Wordpress posts? I want to add a meta tag for keyword. I use Yoast SEO but even though I specify the focus keyword, no keyword is added in the meta ...
0
votes
2answers
866 views

Change default s.w.org dns-prefetch resource hint value

By default, wp_resource_hints() prints hints for s.w.org, I am trying to change the default printed value. I am not trying to get rid of the hook, I indeed need it and want to use it, however witout s....