Questions tagged [wp-head]

Uses do_action() Calls 'wp_head' hook.

Filter by
Sorted by
Tagged with
0
votes
0answers
23 views

Placing CSS/ JS into the header or footer (inline) - trying to apply to several templates

The below code works perfectly well thanks to this help from a previous question I posted. The code that I've posted directly below injects CSS (or JS) into the wp_head of WordPress.... My question ...
2
votes
0answers
61 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 ...
0
votes
1answer
119 views

Wrong image path within inline styles in the head

I'm adding some inline styles to the <head> using file_get_contents(some-style.css) and the wp_head hook. My relative image paths don't work once they are added to the head, although they do ...
0
votes
0answers
58 views

How can I edit a meta description

A shortcode that I'm using in the beginning of each post is somehow getting into the meta description. After trying to figure out why I decided to simply do a preg_replace for the meta description, ...
0
votes
1answer
520 views

Load admin bar without wp_head or wp_footer [duplicate]

Is there any possible way to load admin bar without wp_head or wp_footer? If no, so maybe there is a way to load wp_head() or wp_footer() to catch only admin bar functions, styles and scripts? Is this ...
2
votes
0answers
521 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 ...
0
votes
2answers
3k views

How to properly insert a stylesheet in wp_head

I am generating critical CSS for every page and category. At the moment I am inserting the stylesheet through functions.php like this simply using echo. function criticalCSS_wp_head() { if (...
0
votes
1answer
18 views

Edit meta fields from within template

I am sure this has probably been asked before, but I've tried all sorts of searches and cannot find a definitive answer. Maybe it's just not possible! I have a directory of users (displayed using an "...
0
votes
2answers
952 views

Add inline style to pages where shortcode was used

I am trying to add a style to the header, using this method the style only loads on single posts but if I use a shortcode to load the post content that style does not load in the header: add_action( ...
1
vote
3answers
8k views

Remove meta description on certain pages

Wordpress renders a meta description tag with the content of the blog post as the value for the description. I already generated in the header.php what I want the description to be, no matter what. ...
1
vote
0answers
310 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
971 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', '...
0
votes
1answer
40 views

Calling JavaScript for specific page irrespective of whichever theme you select

I recently added a JavaScript file that pulls JSON data and updates the div tag on specific page of my WordPress, now to apply the JavaScript file to the page I added to header tag in the theme and ...
3
votes
2answers
2k views

How can I get wp_head() as a string instead of echoing it?

I'm using PHP handlebars templates and would like to keep all of the HTML in the template file so I don't have a header.php but rather the handlebars looks like <html> <head> {{#...
3
votes
2answers
293 views

Track down where script is being enqueued from

I have a WordPress site with an SSL certificate. It all works fine, except that this little insecure shield icon shows up because the header has an enqueued non-https script. The issue is that I ...
0
votes
1answer
2k views

Auto Generated HTML source code formatting

I've had this question for a long time and I was wondering if anyone had an answer for it. I know its not really important, but for someone like me who really likes very clean markup things like this ...
1
vote
4answers
11k views

Remove all theme CSS & JS from wp_head (but only for 1 page template)

I have a page template, which is working nicely. But when I include , it loads the themes CSS and js files, which breaks my page template. However, I still need the wp_head for some plugins to work. ...
2
votes
2answers
19k views

How can i remove JUST the title tag from wp_head() function?

i'm using wordpress 4.6 i'd like to remove just the title tag automatically outputted by wordpress because need to hardcode the html title tag in the template. i guess is something like this: ...
0
votes
1answer
373 views

Adding code to head to all pages manually

I've been googling for days and I didn't find a solution. I need to add a JS code to the head of all my pages, and I wanna do that manually (without a plugin). I found a '~/wp-content/themes//header....
0
votes
2answers
1k views

Include HTML (Bootstrap Modal Box) with a plugin into my header

I want to include some HTML, spezific a bootstrap modal box. This is my function with the HTML part: public function dmd_fav_modal_box() { $content = '<div class="modal fade" id="...
3
votes
4answers
5k views

Modify page title format (when using title-tag)

Currently my page titles are handled by WordPress, in a call to wp_head (I have add_theme_support( 'title-tag' ) in functions.php). I'd like to change the page title format for category archives - ...
1
vote
1answer
64 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 (...
3
votes
3answers
14k views

Remove rel='dns-prefetch' href='//maps.google.com' from wp-head

How to remove this from WP head: <link rel='dns-prefetch' href='//maps.google.com'> I had this also: <link rel='dns-prefetch' href='//s.w.org'> But, I removed it with this code inside ...
2
votes
2answers
3k views

How to add inline css/js inside a shortcode

I'm working on creating a shortcode which is meant to change the css and js dynamically for that shortcode based on the situation. Now the problem is that I not getting a clue about how to use ...
0
votes
1answer
1k views

Custom field as meta description

I want to make a description input field inside the normal post adding page (in the dashboard) so each time I'm posting something I'll be able to handle the description as I like. Then I would target ...
0
votes
1answer
438 views

Output dynamic_sidebar_params in wp_head

I have created a custom widget with a color picker field. Currently there are two ways to output the color picker value for this widget: Inline style. Using the dynamic_sidebar_params filter. With ...
0
votes
1answer
5k views

Cannot retieve the_content() and the_author() - both returning empty strings

I am creating the following code to display open graph meta data in the header of my single.php page add_action('wp_head', 'mycode_add_og_meta_tags', 5); function mycode_add_og_meta_tags () { ?> ...
3
votes
2answers
215 views

Display custom_background outside wp_head()

My theme is a very small one page theme which really doesn't need all the scripts, so I've created a few options to remove wp_head() and wp_footer() so the user can choose if they want to enable or ...
4
votes
1answer
6k 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 ...
0
votes
1answer
215 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?
6
votes
3answers
10k views

Is there a way to read or list wp_head() contents?

I am working on a CSS and JS compiler and need to find a way to list the contents of wp_head() I am trying to get a list of all CSS/JS files and inline CSS on any give page. Hooking on the wp_head ...
0
votes
2answers
2k views

Custom script file enqueue has "?ver=4.5.1" when loading and doesn't update

I'm loading a custom script file using an enqueue and here's the output: <script type='text/javascript' src='.../wp-content/themes/enfold-child/js/custom_script.js?ver=4.5.1'></script> ...
0
votes
2answers
588 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
1answer
97 views

How to check widget-cpt meta and display its custom css in the head?

When dealing with a widget that is a custom post type, is there a way to detect when that widget is displayed, then check its post meta for any custom css and enqueue it in the head of the site? ...
2
votes
1answer
5k views

Putting content into header.php without using wp_head

I am building a plugin. I have to output certain stuff in the header.php file of the theme depending on if/else I will write. However I am not at that point yet. I just learned in order to push the ...
0
votes
2answers
4k views

How to output wp_enqueue_style() in HTML head instead of footer

I added some actions to wp_enqueue_scripts to load my custom css and js files in the header section by using wp_head(); right before the closing </head> tag. function mytheme_scripts(){ // ...
3
votes
3answers
6k views

How to control initial wp_head() output?

I followed the common advise to use wp_head() in header.php and wp_enqueue_scripts() instead of hard linking css and js files in header.php. However, I realized that wp_head() outputs lots of stuff I'...
0
votes
1answer
59 views

Grab ID from post from plugin and use it to create an object

I want to create an object and set ID for this object like $p = new Product(87); I have this code within a plugin and I want to grab the ID of the custom post being showed: function getPostId(){ ...
2
votes
1answer
4k views

Remove specific CSS and JS from the head

I'm trying to remove some specific lines from the WP_HEAD. Now my header looks following way: <link rel='stylesheet' id='bootstrap-css' href='/themes/wp-e/css/bootstrap.css?ver=4.2.2' type='text/...
7
votes
3answers
2k views

Any advantage of using wp_scripts and is_IE when enqueuing scripts

I read on the WP docs, which pointed to this gist that the correct way to enqueue styles for IE is by using the $wp_styles. I'm guessing that this would be true then for scripts as well. Take these ...
0
votes
1answer
923 views

custom COOKIE on custom page

i have problem with create function for set cookie dynamically. when i try in custom page i have of course header is set and i tried something like this: in custompage.php: myfunction($cookiename,$...
1
vote
1answer
67 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
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{ ...
0
votes
0answers
212 views

Put dynamic Javascript in header after doing operations

I want to write a plugin that enables a function to be put in my theme in various places. Then I would like to collect the parameters called and generate a Javascript and put it into my site <head&...
0
votes
4answers
5k 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
9k views

using wp_head in body tag for css style

I am trying to add css code into head tag. the css style is from shortcodes. title text from shortcode and title color / font size.. etc. This is an example. <html> <head> <?php ...
0
votes
2answers
2k views

add_action to wp_head is added, but not called

I'm using the CiviCRM plugin for WordPress, and in the plugin's main file, civicrm.php, it calls add_action() to add a function to wp_head() in order to merge CiviCRM's header with my theme's header: ...
6
votes
1answer
5k views

wp_head() gives me some weird CSS

I was trying to enqueue my stylesheets but it didn't work. Turns out I had forgotten to include wp_head() inside my <head> tag. So I did and then my stylesheets where loading fine. The problem ...
0
votes
1answer
664 views

How to style injected code in header section?

Trying to add custom code to header section <head>..</head>of the blog by adding this code to child-theme functions.php // Add scripts to wp_head() function child_theme_head_script() { ...
0
votes
2answers
122 views

Best use adding user generated JS/CSS to a theme with a plugin

I want to know the best use of adding custom JS/CSS to a theme. I have built a small plugin which has a section to allow users to add CSS/JS to their theme. Now I am trying to figure out is which is ...